Skip to content

Commit

Permalink
Generate docs for each field
Browse files Browse the repository at this point in the history
  • Loading branch information
pepsighan committed Dec 10, 2020
1 parent 31c2aec commit 33cf845
Show file tree
Hide file tree
Showing 2 changed files with 11,715 additions and 5 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ const util = require("@mdi/util");
const meta = util.getMeta(true);

const find = /(\-\w)/g;
const convert = function(matches) {
const convert = function (matches) {
return matches[1].toUpperCase();
};

const lines = meta.map(icon => {
const lines = meta.map((icon) => {
let name = icon.name.replace(find, convert);
name = `${name[0].toLowerCase()}${name.slice(1)}`;

if (["null", "switch", "sync", "factory"].includes(name)) {
name = `${name}Icon`;
}

return ` static const ${name} = MdiIconData(0x${icon.codepoint});`;
return ` /// Icon for ${icon.name}.
static const ${name} = MdiIconData(0x${icon.codepoint});
`;
});

const output = `// Material Design Icons v${util.getVersion()}
Expand All @@ -35,7 +37,6 @@ class MdiIconData extends IconData {
/// Mdi is a collection of icons provided by
/// [Material Design Icons](https://materialdesignicons.com/).
class Mdi {
${lines.join("\n")}
}
Expand Down
Loading

0 comments on commit 33cf845

Please sign in to comment.