Skip to content

Commit

Permalink
add: documented percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
llgava committed Sep 23, 2023
1 parent ecb0c81 commit 2b7d5a5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/collectFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ const ignoredFiles = [
'.prettierrc.json',
];

/* Collect all the features a */
export async function collectFeatures(table) {
const files = await glob('**/*.json', { ignore: ignoredFiles });
const addedFeatures = [];
const documentedFeatures = 0;
const undocumentedFeatures = 0;

files.sort((x, y) => x.localeCompare(y));

Expand All @@ -31,5 +34,17 @@ export async function collectFeatures(table) {

addedFeatures.push(feature.identifier);
table.push([feature.MDLink, feature.version, feature.description]);

if (feature.description.length <= 0 || feature.description == null) {
undocumentedFeatures++;
} else {
documentedFeatures++;
}
});

return {
features: table,
documented: documentedFeatures,
undocumented: undocumentedFeatures,
};
}
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ const tableHeader = ['Feature', 'Added Version', 'Description'];
const tableConfig = { align: ['l', 'c'] };

async function main() {
await collectFeatures(table);
const collectedFeatures = await collectFeatures(table);
await formatJSONFiles();

table.unshift(tableHeader);
collectedFeatures.features.unshift(tableHeader);
const percentageCollected = (collectedFeatures.documented / collectedFeatures.features.length) * 100;

const MDTable = markdownTable(table, tableConfig);
const MDTable = markdownTable(collectedFeatures.features, tableConfig);

const templateContent = fs.readFileSync(templateFilePath, 'utf-8');
const readmeContent = templateContent.replace('%markdown_feature_table%', MDTable);
const readmeContent = templateContent
.replace('%collected%', percentageCollected)
.replace('%markdown_feature_table%', MDTable);

fs.writeFileSync(readmeFilePath, readmeContent);
}
Expand Down
2 changes: 2 additions & 0 deletions src/template/README_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ All features are saved according to the Major version of the game, that is, feat
**Add Version** refers to when the feature file was added to vanilla behavior pack. Note that only the Major Version is used for versioning.

## Vanilla Features
![Documentation Status](https://progress-bar.dev/%collected%/?title=Docs&scale=100&suffix=%&color=353C43)

%markdown_feature_table%

## Contributors
Expand Down

0 comments on commit 2b7d5a5

Please sign in to comment.