Skip to content

Commit

Permalink
📖 Move extension markdown template into its own file (ampproject#25164)
Browse files Browse the repository at this point in the history
Keeps `${name}` and `${year}` as interpolation tokens.
  • Loading branch information
alanorozco authored and Micajuine Ho committed Dec 27, 2019
1 parent c2dd8fd commit 6020042
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 84 deletions.
79 changes: 79 additions & 0 deletions build-system/tasks/extension-generator/extension-doc.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!--
1. Change "category" below to one of:
ads-analytics
dynamic-content
layout
media
presentation
social
2. Remove any of the "formats" that don't apply.
You can also add the "ads" and "stories" formats if they apply.
3. And remove this comment! (no empty lines before "---")
-->
---
$category: presentation
formats:
- websites
- email
teaser:
text: FILL THIS IN.
---
<!--
Copyright ${year} The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# \`${name}\`

<table>
<tr>
<td width="40%"><strong>Description</strong></td>
<td>FILL THIS IN</td>
</tr>
<tr>
<td width="40%"><strong>Availability</strong></td>
<td>FILL THIS IN</td>
</tr>
<tr>
<td width="40%"><strong>Required Script</strong></td>
<td><code>&lt;script async custom-element="${name}" src="https://cdn.ampproject.org/v0/${name}-0.1.js">&lt;/script></code></td>
</tr>
<tr>
<td class="col-fourty"><strong><a href="https://amp.dev/documentation/guides-and-tutorials/develop/style_and_layout/control_layout">Supported Layouts</a></strong></td>
<td>FILL THIS IN</td>
</tr>
<tr>
<td width="40%"><strong>Examples</strong></td>
<td>FILL THIS IN</td>
</tr>
</table>

## Behavior

FILL THIS IN. What does this extension do?

## Attributes

FILL THIS IN. Does this extension allow for properties to configure?

<table>
<tr>
<td width="40%"><strong>data-my-attribute</strong></td>
<td>FILL THIS IN. This table <strong>must</strong> be written in HTML.</td>
</tr>
</table>

## Validation

See [${name} rules](https://github.com/ampproject/amphtml/blob/master/extensions/${name}/validator-${name}.protoascii) in the AMP validator specification.
90 changes: 6 additions & 84 deletions build-system/tasks/extension-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,89 +73,11 @@ tags: { # <${name}>
`;
}

function getMarkdownExtensionFile(name) {
return `<!--
1. Change "category" below to one of:
ads-analytics
dynamic-content
layout
media
presentation
social
2. Remove any of the "formats" that don't apply.
You can also add the "ads" and "stories" formats if they apply.
3. And remove this comment! (no empty lines before "---")
-->
---
$category: presentation
formats:
- websites
- email
teaser:
text: FILL THIS IN.
---
<!--
Copyright ${year} The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
# \`${name}\`
<table>
<tr>
<td width="40%"><strong>Description</strong></td>
<td>FILL THIS IN</td>
</tr>
<tr>
<td width="40%"><strong>Availability</strong></td>
<td>FILL THIS IN</td>
</tr>
<tr>
<td width="40%"><strong>Required Script</strong></td>
<td><code>&lt;script async custom-element="${name}" src="https://cdn.ampproject.org/v0/${name}-0.1.js">&lt;/script></code></td>
</tr>
<tr>
<td class="col-fourty"><strong><a href="https://amp.dev/documentation/guides-and-tutorials/develop/style_and_layout/control_layout">Supported Layouts</a></strong></td>
<td>FILL THIS IN</td>
</tr>
<tr>
<td width="40%"><strong>Examples</strong></td>
<td>FILL THIS IN</td>
</tr>
</table>
## Behavior
FILL THIS IN. What does this extension do?
## Attributes
FILL THIS IN. Does this extension allow for properties to configure?
<table>
<tr>
<td width="40%"><strong>data-my-attribute</strong></td>
<td>FILL THIS IN. This table <strong>must</strong> be written in HTML.</td>
</tr>
</table>
## 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 `/**
Expand Down Expand Up @@ -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`,
Expand Down

0 comments on commit 6020042

Please sign in to comment.