Skip to content

Commit

Permalink
docs: remove lint badge
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Apr 24, 2023
1 parent aac13f5 commit 44b6ada
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 47 deletions.
61 changes: 29 additions & 32 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ You can use [GitHub's theme context](https://github.blog/changelog/2021-11-24-sp
##### Use GitHub's new media feature

You can use [GitHub's new media feature](https://github.blog/changelog/2022-05-19-specify-theme-context-for-images-in-markdown-beta/) in HTML to specify whether to display images for light or dark themes. This is done using the HTML `<picture>` element in combination with the `prefers-color-scheme` media feature.

```html
<picture>
<source
Expand Down Expand Up @@ -309,8 +309,8 @@ You can provide multiple comma-separated values in the bg_color option to render
- `custom_title` - Sets a custom title for the card _(string)_. Default `Most Used Languages`.
- `disable_animations` - Disables all animations in the card _(boolean)_. Default: `false`.
- `hide_progress` - It uses the compact layout option, hides percentages, and removes the bars. Default: `false`.
- `p` - Configures ranking algorithm, defaults to 1, recommended is 0.5 _(number)_
- `q` - Configures ranking algorithm, defaults to 0, recommended is 0.5 _(number)_
- `p` - Configures language stats algorithm _(number)_ (see [Language stats algorithm](#Language-stats-algorithm)), defaults to 1.
- `q` - Configures language stats algorithm _(number)_ (see [Language stats algorithm](#Language-stats-algorithm)), defaults to 0.

> **Warning**
> Language names should be URI-escaped, as specified in [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
Expand Down Expand Up @@ -347,26 +347,6 @@ Endpoint: `api/pin?username=anuraghazra&repo=github-readme-stats`
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats)](https://github.com/anuraghazra/github-readme-stats)
```

### Ranking configuration

You can use the `&p=` and `&q=` options to change the method used to rank the languages used. The values must be positive real numbers.

The algorithm used is

```javascript
ranking_index = (byte_count ^ p) * (repo_count ^ q)
```

[Details here.](https://github.com/anuraghazra/github-readme-stats/issues/1600#issuecomment-1046056305)

- `&p=1&q=0` - _(default)_ Orders by byte count
- `&p=0.5&q=0.5` - _(recommended)_ Uses both byte and repo count for ranking
- `&p=0&q=1` - Orders by repo count

```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&p=0.5&q=0.5)](https://github.com/anuraghazra/github-readme-stats)
```

### Demo

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats)](https://github.com/anuraghazra/github-readme-stats)
Expand All @@ -382,6 +362,23 @@ The top languages card shows a GitHub user's most frequently used top language.
> **Note**
> Top Languages does not indicate my skill level or anything like that; it's a GitHub metric to determine which languages have the most code on GitHub. It is a new feature of github-readme-stats.
### Language stats algorithm

We use the following algorithm to calculate the languages percentages on the language card:

```js
ranking_index = (byte_count ^ p) * (repo_count ^ q)
```
By default, only the byte count is used for determining the languages percentages shown on the language card (i.e. `p=1` and `q=0`). You can, however, use the `&p=` and `&q=` options to weight the language usage calculation. The values must be positive real numbers. More details about the algorithm can be found [here](Details here.](https://github.com/anuraghazra/github-readme-stats/issues/1600#issuecomment-1046056305)).

- `&p=1&q=0` - _(default)_ Orders by byte count.
- `&p=0.5&q=0.5` - _(recommended)_ Uses both byte and repo count for ranking
- `&p=0&q=1` - Orders by repo count

```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&p=0.5&q=0.5)](https://github.com/anuraghazra/github-readme-stats)
```

### Usage

Copy-paste this code into your readme and change the links.
Expand Down Expand Up @@ -440,7 +437,7 @@ You can use the `&hide_progress=true` option to hide the percentages and the pro

[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&layout=compact)](https://github.com/anuraghazra/github-readme-stats)

- Hidden progress bars
- Hidden progress bars

[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&hide_progress=true)](https://github.com/anuraghazra/github-readme-stats)

Expand Down Expand Up @@ -581,14 +578,14 @@ Since the GitHub API only allows 5k requests per hour, my `https://github-readme
<details>
<summary><b>:hammer_and_wrench: Step-by-step guide for deploying on other platforms</b></summary>

1. Fork or clone this repo as per your needs
2. Add `express` to the dependencies section of `package.json`
https://github.com/anuraghazra/github-readme-stats/blob/ba7c2f8b55eac8452e479c8bd38b044d204d0424/package.json#L54-L61
3. Run `npm i` if needed (initial setup)
4. Run `node express.js` to start the server, or set the entry point to `express.js` in `package.json` if you're deploying on a managed service
https://github.com/anuraghazra/github-readme-stats/blob/ba7c2f8b55eac8452e479c8bd38b044d204d0424/package.json#L11
5. You're done 🎉
</details>
1. Fork or clone this repo as per your needs
2. Add `express` to the dependencies section of `package.json`
<https://github.com/anuraghazra/github-readme-stats/blob/ba7c2f8b55eac8452e479c8bd38b044d204d0424/package.json#L54-L61>
3. Run `npm i` if needed (initial setup)
4. Run `node express.js` to start the server, or set the entry point to `express.js` in `package.json` if you're deploying on a managed service
<https://github.com/anuraghazra/github-readme-stats/blob/ba7c2f8b55eac8452e479c8bd38b044d204d0424/package.json#L11>
5. You're done 🎉
</details>

### Keep your fork up to date

Expand Down
18 changes: 8 additions & 10 deletions src/fetchers/top-languages-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ const fetchTopLanguages = async (username, exclude_repo = [], p = 1, q = 0) => {
// add the size to the language size and increase repoCount.
if (acc[prev.node.name] && prev.node.name === acc[prev.node.name].name) {
langSize = prev.size + acc[prev.node.name].size;
repoCount = repoCount + 1;
}
else {
repoCount += 1;
} else {
// reset repoCount to 1
// language must exist in atleast one repo to be detected
// language must exist in at least one repo to be detected
repoCount = 1;
}
return {
Expand All @@ -134,12 +133,11 @@ const fetchTopLanguages = async (username, exclude_repo = [], p = 1, q = 0) => {
};
}, {});


Object.keys(repoNodes)
.forEach((name) => {
// comparison index calculation
repoNodes[name].size = Math.pow(repoNodes[name].size, p) * Math.pow(repoNodes[name].count, q);
})
Object.keys(repoNodes).forEach((name) => {
// comparison index calculation
repoNodes[name].size =
Math.pow(repoNodes[name].size, p) * Math.pow(repoNodes[name].count, q);
});

const topLangs = Object.keys(repoNodes)
.sort((a, b) => repoNodes[b].size - repoNodes[a].size)
Expand Down
10 changes: 5 additions & 5 deletions tests/fetchTopLanguages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ describe("FetchTopLanguages", () => {
it("should fetch correct language data while using the new calculation", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);

let repo = await fetchTopLanguages("anuraghazra", p = 0.5, q = 0.5);
let repo = await fetchTopLanguages("anuraghazra", [], 0.5, 0.5);
expect(repo).toStrictEqual({
HTML: {
color: "#0f0",
count: 2,
name: "HTML",
size: 20,
size: 20.000000000000004,
},
javascript: {
color: "#0ff",
count: 2,
name: "javascript",
size: 20,
size: 20.000000000000004,
},
});
});
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("FetchTopLanguages", () => {
it("should fetch correct language data while using the old calculation", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);

let repo = await fetchTopLanguages("anuraghazra", p = 1, q = 0);
let repo = await fetchTopLanguages("anuraghazra", [], 1, 0);
expect(repo).toStrictEqual({
HTML: {
color: "#0f0",
Expand All @@ -123,7 +123,7 @@ describe("FetchTopLanguages", () => {
it("should rank languages by the number of repositories they appear in", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);

let repo = await fetchTopLanguages("anuraghazra", exclude_repo = [], p = 0, q = 1);
let repo = await fetchTopLanguages("anuraghazra", [], 0, 1);
expect(repo).toStrictEqual({
HTML: {
color: "#0f0",
Expand Down

0 comments on commit 44b6ada

Please sign in to comment.