diff --git a/build-system/tasks/extension-generator/extension-doc.template.md b/build-system/tasks/extension-generator/extension-doc.template.md new file mode 100644 index 000000000000..b0ab895f6b20 --- /dev/null +++ b/build-system/tasks/extension-generator/extension-doc.template.md @@ -0,0 +1,79 @@ + +--- +$category: presentation +formats: + - websites + - email +teaser: + text: FILL THIS IN. +--- + + +# \`${name}\` + + + + + + + + + + + + + + + + + + + + + + +
DescriptionFILL THIS IN
AvailabilityFILL THIS IN
Required Script<script async custom-element="${name}" src="https://cdn.ampproject.org/v0/${name}-0.1.js"></script>
Supported LayoutsFILL THIS IN
ExamplesFILL THIS IN
+ +## Behavior + +FILL THIS IN. What does this extension do? + +## Attributes + +FILL THIS IN. Does this extension allow for properties to configure? + + + + + + +
data-my-attributeFILL THIS IN. This table must be written in HTML.
+ +## Validation + +See [${name} rules](https://github.com/ampproject/amphtml/blob/master/extensions/${name}/validator-${name}.protoascii) in the AMP validator specification. diff --git a/build-system/tasks/extension-generator/index.js b/build-system/tasks/extension-generator/index.js index abacd6a81b0a..eff0492b4b37 100644 --- a/build-system/tasks/extension-generator/index.js +++ b/build-system/tasks/extension-generator/index.js @@ -73,89 +73,11 @@ tags: { # <${name}> `; } -function getMarkdownExtensionFile(name) { - return ` ---- -$category: presentation -formats: - - websites - - email -teaser: - text: FILL THIS IN. ---- - - -# \`${name}\` - - - - - - - - - - - - - - - - - - - - - - -
DescriptionFILL THIS IN
AvailabilityFILL THIS IN
Required Script<script async custom-element="${name}" src="https://cdn.ampproject.org/v0/${name}-0.1.js"></script>
Supported LayoutsFILL THIS IN
ExamplesFILL THIS IN
- -## Behavior - -FILL THIS IN. What does this extension do? - -## Attributes - -FILL THIS IN. Does this extension allow for properties to configure? - - - - - - -
data-my-attributeFILL THIS IN. This table must be written in HTML.
- -## Validation -See [${name} rules](https://github.com/ampproject/amphtml/blob/master/extensions/${name}/validator-${name}.protoascii) in the AMP validator specification. -`; -} +const getMarkdownDocFile = async name => + (await fs.readFile(`${__dirname}/extension-doc.template.md`)) + .toString('utf-8') + .replace(/\${name}/g, name) + .replace(/\${year}/g, year); function getJsTestExtensionFile(name) { return `/** @@ -286,7 +208,7 @@ async function makeExtension() { fs.mkdirpSync(`extensions/${name}/0.1/test`); fs.writeFileSync( `extensions/${name}/${name}.md`, - getMarkdownExtensionFile(name) + await getMarkdownDocFile(name) ); fs.writeFileSync( `extensions/${name}/validator-${name}.protoascii`,