Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit343058c

Browse files
fix: adding doc strings to files in src folder where it was missing (anuraghazra#2129)
* fix: adding doc strings to files in src folder where it was missing* refactor: add docstrings* style: run formatterCo-authored-by: rickstaa <rick.staa@outlook.com>
1 parentd7451d8 commit343058c

15 files changed

+322
-174
lines changed

‎src/calculateRank.js‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*
55
*@see https://stackoverflow.com/a/5263759/10629172
66
*
7-
*@param {string} mean
8-
*@param {number} sigma
9-
*@param {number} to
7+
*@param {string} mean The mean of the normal distribution.
8+
*@param {number} sigma The standard deviation of the normal distribution.
9+
*@param {number} to The value to calculate the probability for.
1010
*@returns {number} Probability.
1111
*/
1212
functionnormalcdf(mean,sigma,to){
@@ -29,13 +29,13 @@ function normalcdf(mean, sigma, to) {
2929
/**
3030
* Calculates the users rank.
3131
*
32-
*@param {number} totalRepos
33-
*@param {number} totalCommits
34-
*@param {number} contributions
35-
*@param {number} followers
36-
*@param {number} prs
37-
*@param {number} issues
38-
*@param {number} stargazers
32+
*@param {number} totalRepos Total number of repos.
33+
*@param {number} totalCommits Total number of commits.
34+
*@param {number} contributions The number of contributions.
35+
*@param {number} followers The number of followers.
36+
*@param {number} prs The number of pull requests.
37+
*@param {number} issues The number of issues.
38+
*@param {number} stargazers The number of stars.
3939
*@returns {{level: string, score: number}}} The users rank.
4040
*/
4141
functioncalculateRank({

‎src/cards/repo-card.js‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import {
1414
import{repoCardLocales}from"../translations.js";
1515

1616
/**
17-
*@param {string} label
18-
*@param {string} textColor
19-
*@returns {string}
17+
* Retrieves the repository description and wraps it to fit the card width.
18+
*
19+
*@param {string} label The repository description.
20+
*@param {string} textColor The color of the text.
21+
*@returns {string} Wrapped repo description SVG object.
2022
*/
2123
constgetBadgeSVG=(label,textColor)=>`
2224
<g data-testid="badge" class="badge" transform="translate(320, -18)">
@@ -34,9 +36,11 @@ const getBadgeSVG = (label, textColor) => `
3436
`;
3537

3638
/**
37-
*@param {string} langName
38-
*@param {string} langColor
39-
*@returns {string}
39+
* Creates a node to display the primary programming language of the repository.
40+
*
41+
*@param {string} langName Language name.
42+
*@param {string} langColor Language color.
43+
*@returns {string} Language display SVG object.
4044
*/
4145
constcreateLanguageNode=(langName,langColor)=>{
4246
return`
@@ -48,6 +52,15 @@ const createLanguageNode = (langName, langColor) => {
4852
};
4953

5054
constICON_SIZE=16;
55+
56+
/**
57+
* Creates an icon with label to display repository stats like forks, stars, etc.
58+
*
59+
*@param {string} icon The icon to display.
60+
*@param {number|string} label The label to display.
61+
*@param {string} testid The testid to assign to the label.
62+
*@returns {string} Icon with label SVG object.
63+
*/
5164
consticonWithLabel=(icon,label,testid)=>{
5265
if(label<=0)return"";
5366
consticonSvg=`
@@ -67,9 +80,11 @@ const iconWithLabel = (icon, label, testid) => {
6780
};
6881

6982
/**
70-
*@param {import('../fetchers/types').RepositoryData} repo
71-
*@param {Partial<import("./types").RepoCardOptions>} options
72-
*@returns {string}
83+
* Renders repository card details.
84+
*
85+
*@param {import('../fetchers/types').RepositoryData} repo Repository data.
86+
*@param {Partial<import("./types").RepoCardOptions>} options Card options.
87+
*@returns {string} Repository card SVG object.
7388
*/
7489
constrenderRepoCard=(repo,options={})=>{
7590
const{

‎src/cards/stats-card.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ const createTextNode = ({
6363
};
6464

6565
/**
66-
*@param {Partial<import('../fetchers/types').StatsData>} stats
67-
*@param {Partial<import("./types").StatCardOptions>} options
68-
*@returns {string}
66+
* Renders the stats card.
67+
*
68+
*@param {Partial<import('../fetchers/types').StatsData>} stats The stats data.
69+
*@param {Partial<import("./types").StatCardOptions>} options The card options.
70+
*@returns {string} The stats card SVG object.
6971
*/
7072
constrenderStatsCard=(stats={},options={hide:[]})=>{
7173
const{

‎src/cards/top-languages-card.js‎

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const CARD_PADDING = 25;
2323
*/
2424

2525
/**
26-
*@param {Lang[]} arr
26+
* Retrieves the programming language whose name is the longest.
27+
*
28+
*@param {Lang[]} arr Array of programming languages.
29+
*@returns {Object} Longest programming language object.
2730
*/
2831
constgetLongestLang=(arr)=>
2932
arr.reduce(
@@ -33,12 +36,15 @@ const getLongestLang = (arr) =>
3336
);
3437

3538
/**
36-
*@param {{
37-
* width: number,
38-
* color: string,
39-
* name: string,
40-
* progress: string
41-
* }} props
39+
* Creates a node to display usage of a programming language in percentage
40+
* using text and a horizontal progress bar.
41+
*
42+
*@param {object[]} props Function properties.
43+
*@param {number} props.width The card width
44+
*@param {string} props.name Name of the programming language.
45+
*@param {string} props.color Color of the programming language.
46+
*@param {string} props.progress Usage of the programming language in percentage.
47+
*@returns {string} Programming language SVG node.
4248
*/
4349
constcreateProgressTextNode=({ width, color, name, progress})=>{
4450
constpaddingRight=95;
@@ -60,7 +66,12 @@ const createProgressTextNode = ({ width, color, name, progress }) => {
6066
};
6167

6268
/**
63-
*@param {{ lang: Lang, totalSize: number }} props
69+
* Creates a text only node to display usage of a programming language in percentage.
70+
*
71+
*@param {object[]} props Function properties.
72+
*@param {Lang} props.lang Programming language object.
73+
*@param {number} props.totalSize Total size of all languages.
74+
*@returns {string} Compact layout programming language SVG node.
6475
*/
6576
constcreateCompactLangNode=({ lang, totalSize})=>{
6677
constpercentage=((lang.size/totalSize)*100).toFixed(2);
@@ -77,7 +88,12 @@ const createCompactLangNode = ({ lang, totalSize }) => {
7788
};
7889

7990
/**
80-
*@param {{ langs: Lang[], totalSize: number }} props
91+
* Creates compact layout of text only language nodes.
92+
*
93+
*@param {object[]} props Function properties.
94+
*@param {Lang[]} props.langs Array of programming languages.
95+
*@param {number} props.totalSize Total size of all languages.
96+
*@returns {string} Programming languages SVG node.
8197
*/
8298
constcreateLanguageTextNode=({ langs, totalSize})=>{
8399
constlongestLang=getLongestLang(langs);
@@ -109,10 +125,12 @@ const createLanguageTextNode = ({ langs, totalSize }) => {
109125
};
110126

111127
/**
112-
*@param {Lang[]} langs
113-
*@param {number} width
114-
*@param {number} totalLanguageSize
115-
*@returns {string}
128+
* Renders layout to display user's most frequently used programming languages.
129+
*
130+
*@param {Lang[]} langs Array of programming languages.
131+
*@param {number} width Card width.
132+
*@param {number} totalLanguageSize Total size of all languages.
133+
*@returns {string} Normal layout card SVG object.
116134
*/
117135
constrenderNormalLayout=(langs,width,totalLanguageSize)=>{
118136
returnflexLayout({
@@ -130,10 +148,12 @@ const renderNormalLayout = (langs, width, totalLanguageSize) => {
130148
};
131149

132150
/**
133-
*@param {Lang[]} langs
134-
*@param {number} width
135-
*@param {number} totalLanguageSize
136-
*@returns {string}
151+
* Renders compact layout to display user's most frequently used programming languages.
152+
*
153+
*@param {Lang[]} langs Array of programming languages.
154+
*@param {number} width Card width.
155+
*@param {number} totalLanguageSize Total size of all languages.
156+
*@returns {string} Compact layout card SVG object.
137157
*/
138158
constrenderCompactLayout=(langs,width,totalLanguageSize)=>{
139159
constpaddingRight=50;
@@ -181,26 +201,31 @@ const renderCompactLayout = (langs, width, totalLanguageSize) => {
181201
};
182202

183203
/**
184-
*@param {number} totalLangs
185-
*@returns {number}
204+
* Calculates height for the compact layout.
205+
*
206+
*@param {number} totalLangs Total number of languages.
207+
*@returns {number} Card height.
186208
*/
187209
constcalculateCompactLayoutHeight=(totalLangs)=>{
188210
return90+Math.round(totalLangs/2)*25;
189211
};
190212

191213
/**
192-
*@param {number} totalLangs
193-
*@returns {number}
214+
* Calculates height for the normal layout.
215+
*
216+
*@param {number} totalLangs Total number of languages.
217+
*@returns {number} Card height.
194218
*/
195219
constcalculateNormalLayoutHeight=(totalLangs)=>{
196220
return45+(totalLangs+1)*40;
197221
};
198222

199223
/**
224+
* Hides languages and trims the list to show only the top N languages.
200225
*
201-
*@param {Record<string, Lang>} topLangs
202-
*@param {string[]} hide
203-
*@param {string} langs_count
226+
*@param {Record<string, Lang>} topLangs Top languages.
227+
*@param {string[]} hide Languages to hide.
228+
*@param {string} langs_count Number of languages to show.
204229
*/
205230
constuseLanguages=(topLangs,hide,langs_count)=>{
206231
letlangs=Object.values(topLangs);
@@ -229,9 +254,11 @@ const useLanguages = (topLangs, hide, langs_count) => {
229254
};
230255

231256
/**
232-
*@param {import('../fetchers/types').TopLangData} topLangs
233-
*@param {Partial<import("./types").TopLangOptions>} options
234-
*@returns {string}
257+
* Renders card to display user's most frequently used programming languages.
258+
*
259+
*@param {import('../fetchers/types').TopLangData} topLangs User's most frequently used programming languages.
260+
*@param {Partial<import("./types").TopLangOptions>} options Card options.
261+
*@returns {string} Language card SVG object.
235262
*/
236263
constrenderTopLanguages=(topLangs,options={})=>{
237264
const{

‎src/cards/wakatime-card.js‎

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const require = createRequire(import.meta.url);
2323
constlanguageColors=require("../common/languageColors.json");// now works
2424

2525
/**
26-
*@param {{color: string, text: string}} param0
26+
* Creates the no coding activity SVG node.
27+
*
28+
*@param {{color: string, text: string}} The function prop
2729
*/
2830
constnoCodingActivityNode=({ color, text})=>{
2931
return`
@@ -32,13 +34,13 @@ const noCodingActivityNode = ({ color, text }) => {
3234
};
3335

3436
/**
37+
* Create compact WakaTime layout.
3538
*
36-
*@param {{
37-
* lang: import("../fetchers/types").WakaTimeLang,
38-
* totalSize: number,
39-
* x: number,
40-
* y: number
41-
* }} props
39+
*@param {Object[]} args The function arguments.
40+
*@param {import("../fetchers/types").WakaTimeLang[]} languages The languages array.
41+
*@param {number} totalSize The total size of the languages.
42+
*@param {number} x The x position of the language node.
43+
*@param {number} y The y position of the language node.
4244
*/
4345
constcreateCompactLangNode=({ lang, totalSize, x, y})=>{
4446
constcolor=languageColors[lang.name]||"#858585";
@@ -54,12 +56,13 @@ const createCompactLangNode = ({ lang, totalSize, x, y }) => {
5456
};
5557

5658
/**
57-
*@param {{
58-
* langs: import("../fetchers/types").WakaTimeLang[],
59-
* totalSize: number,
60-
* x: number,
61-
* y: number
62-
* }} props
59+
* Create WakaTime language text node item.
60+
*
61+
*@param {Object[]} args The function arguments.
62+
*@param {import("../fetchers/types").WakaTimeLang} lang The language object.
63+
*@param {number} totalSize The total size of the languages.
64+
*@param {number} x The x position of the language node.
65+
*@param {number} y The y position of the language node.
6366
*/
6467
constcreateLanguageTextNode=({ langs, totalSize, x, y})=>{
6568
returnlangs.map((lang,index)=>{
@@ -81,17 +84,16 @@ const createLanguageTextNode = ({ langs, totalSize, x, y }) => {
8184
};
8285

8386
/**
87+
* Create WakaTime text item.
8488
*
85-
*@param {{
86-
* id: string;
87-
* label: string;
88-
* value: string;
89-
* index: number;
90-
* percent: number;
91-
* hideProgress: boolean;
92-
* progressBarColor: string;
93-
* progressBarBackgroundColor: string
94-
* }} props
89+
*@param {Object[]} args The function arguments.
90+
*@param {string} id The id of the text node item.
91+
*@param {string} label The label of the text node item.
92+
*@param {string} value The value of the text node item.
93+
*@param {number} index The index of the text node item.
94+
*@param {percent} percent Percentage of the text node item.
95+
*@param {boolean} hideProgress Whether to hide the progress bar.
96+
*@param {string} progressBarBackgroundColor The color of the progress bar background.
9597
*/
9698
constcreateTextNode=({
9799
id,
@@ -132,11 +134,13 @@ const createTextNode = ({
132134
};
133135

134136
/**
135-
*@param {import("../fetchers/types").WakaTimeLang[]} languages
137+
* Recalculating percentages so that, compact layout's progress bar does not break when
138+
* hiding languages.
139+
*
140+
*@param {import("../fetchers/types").WakaTimeLang[]} languages The languages array.
141+
*@return {import("../fetchers/types").WakaTimeLang[]} The recalculated languages array.
136142
*/
137143
constrecalculatePercentages=(languages)=>{
138-
// recalculating percentages so that,
139-
// compact layout's progress bar does not break when hiding languages
140144
consttotalSum=languages.reduce(
141145
(totalSum,language)=>totalSum+language.percent,
142146
0,
@@ -148,9 +152,11 @@ const recalculatePercentages = (languages) => {
148152
};
149153

150154
/**
151-
*@param {Partial<import('../fetchers/types').WakaTimeData>} stats
152-
*@param {Partial<import('./types').WakaTimeOptions>} options
153-
*@returns {string}
155+
* Renders WakaTime card.
156+
*
157+
*@param {Partial<import('../fetchers/types').WakaTimeData>} stats WakaTime stats.
158+
*@param {Partial<import('./types').WakaTimeOptions>} options Card options.
159+
*@returns {string} WakaTime card SVG.
154160
*/
155161
constrenderWakatimeCard=(stats={},options={hide:[]})=>{
156162
let{ languages}=stats;

‎src/common/Card.js‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import { encodeHTML, flexLayout } from "./utils.js";
33

44
classCard{
55
/**
6-
*@param {object} args
7-
*@param {number?=} args.width
8-
*@param {number?=} args.height
9-
*@param {number?=} args.border_radius
10-
*@param {string?=} args.customTitle
11-
*@param {string?=} args.defaultTitle
12-
*@param {string?=} args.titlePrefixIcon
13-
*@param {ReturnType<import('../common/utils.js').getCardColors>?=} args.colors
6+
* Creates a new card instance.
7+
*
8+
*@param {object} args Card arguments.
9+
*@param {number?=} args.width Card width.
10+
*@param {number?=} args.height Card height.
11+
*@param {number?=} args.border_radius Card border radius.
12+
*@param {string?=} args.customTitle Card custom title.
13+
*@param {string?=} args.defaultTitle Card default title.
14+
*@param {string?=} args.titlePrefixIcon Card title prefix icon.
15+
*@returns {Card} Card instance.
1416
*/
1517
constructor({
1618
width=100,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp