Skip to content

Commit

Permalink
perf(demo): update demo file names #500
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Feb 16, 2024
1 parent 77883d9 commit d3ec997
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/auroLabsMajors.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The next stage to be completed is a thorough code review of the new element. To

## Documentation

The strength of Auro, and any design system, is its docs. To help streamline this process, the custom element demo located at `./demo/demo.md`, is the same document that will be used in the Auro doc site when the new element is released.
The strength of Auro, and any design system, is its docs. To help streamline this process, the custom element demo located at `./demo/index.md`, is the same document that will be used in the Auro doc site when the new element is released.

Because of this, it is important that the demo page is fully reviewed by Alaska UX writers and the Auro team.

Expand Down
2 changes: 1 addition & 1 deletion template/.github/ISSUE_TEMPLATE/publish_component.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ labels: '[namespace]-[name], not-reviewed'
- [ ] All style code follows [Auro's Style Guide](http://auro.alaskaair.com/webcorestylesheets/guidelines)
- [ ] Automated tests created
1. __Documentation__
- `demo.md`
- `index.md`
- [ ] Component properly described
- [ ] Custom element's full API is documented
- [ ] Component use case(s) outlined
Expand Down
4 changes: 2 additions & 2 deletions template/demo/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See LICENSE in the project root for license information.
HTML in this document is standardized and NOT to be edited.
All demo code should be added/edited in ./demo/apiExamples.md
All demo code should be added/edited in ./demo/api.md
With the exception of adding custom elements if needed for the demo.
Expand Down Expand Up @@ -32,7 +32,7 @@
<script type="module">
import 'https://cdn.jsdelivr.net/npm/marked@latest/marked.min.js';
import 'https://cdn.jsdelivr.net/npm/prismjs@latest/prism.js';
fetch('/demo/apiExamples.md')
fetch('/demo/api.md')
.then((response) => response.text())
.then((text) => {
const rawHtml = marked.parse(text);
Expand Down
4 changes: 2 additions & 2 deletions template/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See LICENSE in the project root for license information.
HTML in this document is standardized and NOT to be edited.
All demo code should be added/edited in ./demo/demo.md
All demo code should be added/edited in ./demo/index.md
With the exception of adding custom elements if needed for the demo.
Expand Down Expand Up @@ -32,7 +32,7 @@
<script type="module">
import 'https://cdn.jsdelivr.net/npm/marked@latest/marked.min.js';
import 'https://cdn.jsdelivr.net/npm/prismjs@latest/prism.js';
fetch('/demo/demo.md')
fetch('/demo/index.md')
.then((response) => response.text())
.then((text) => {
const rawHtml = marked.parse(text);
Expand Down
23 changes: 2 additions & 21 deletions template/docs/partials/demo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
The demo.md file is a compiled document. No edits should be made directly to this file.
The index.md file is a compiled document. No edits should be made directly to this file.
README.md is created by running `npm run build:docs`.
This file is generated based on a template fetched from `./docs/partials/demo.md`
This file is generated based on a template fetched from `./docs/partials/index.md`
-->

# [Name]
Expand All @@ -25,25 +25,6 @@ This file is generated based on a template fetched from `./docs/partials/demo.md

Aenean at blandit lorem. Fusce imperdiet mi nec gravida maximus. Quisque nisl libero, condimentum in nisi a, imperdiet lacinia arcu.

```javascript
toggleDialog = (elName) => {
let dialog = document.querySelector(elName);
const html = document.querySelector('html');

html.style.overflow = 'hidden';
dialog.removeAttribute("open");
dialog.setAttribute("open", true);
}

toggleDialogClose = (elName) => {
let dialog = document.querySelector(elName);
const html = document.querySelector('html');

html.style.overflow = '';
dialog.removeAttribute("open");
}
```

## Example(s)

<div class="exampleWrapper">
Expand Down
4 changes: 2 additions & 2 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
"./CHANGELOG.md",
"./README.md",
"./docs/api.md",
"./demo/demo.md",
"./demo/apiExamples.md"
"./demo/index.md",
"./demo/api.md"
]
}
],
Expand Down
28 changes: 14 additions & 14 deletions template/scripts/generateDocs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function formatApiTableContents(content, destination) {

fs.writeFileSync(destination, result, { encoding: 'utf8'});

fs.readFile('./demo/apiExamples.md', 'utf8', function(err, data) {
formatTemplateFileContents(data, './demo/apiExamples.md');
fs.readFile('./demo/api.md', 'utf8', function(err, data) {
formatTemplateFileContents(data, './demo/api.md');
});
}

Expand Down Expand Up @@ -114,17 +114,17 @@ function processReadme() {
}

/**
* Compiles `./docTemplates/demo.md` -> `./demo/demo.md`
* Compiles `./docs/partials/index.md` -> `./demo/index.md`
*/

function processDemo() {
const callback = function(updatedContent, outputConfig) {
if (fs.existsSync('./demo/demo.md')) {
fs.readFile('./demo/demo.md', 'utf8', function(err, data) {
formatTemplateFileContents(data, './demo/demo.md');
if (fs.existsSync('./demo/index.md')) {
fs.readFile('./demo/index.md', 'utf8', function(err, data) {
formatTemplateFileContents(data, './demo/index.md');
});
} else {
console.log('ERROR: ./demo/demo.md file is missing');
console.log('ERROR: ./demo/index.md file is missing');
}
};

Expand All @@ -133,23 +133,23 @@ function processDemo() {
outputDir: './demo'
};

const markdownPath = path.join(__dirname, '../docs/partials/demo.md');
const markdownPath = path.join(__dirname, '../docs/partials/index.md');

markdownMagic(markdownPath, configDemo, callback);
}

/**
* Compiles `./docTemplates/apiExamples.md` -> `./demo/apiExamples.md`
* Compiles `./docs/partials/api.md` -> `./demo/api.md`
*/

function processApiExamples() {
const callback = function(updatedContent, outputConfig) {
if (fs.existsSync('./demo/apiExamples.md')) {
fs.readFile('./demo/apiExamples.md', 'utf8', function(err, data) {
formatApiTableContents(data, './demo/apiExamples.md');
if (fs.existsSync('./demo/api.md')) {
fs.readFile('./demo/api.md', 'utf8', function(err, data) {
formatApiTableContents(data, './demo/api.md');
});
} else {
console.log('ERROR: ./demo/apiExamples.md file is missing');
console.log('ERROR: ./demo/api.md file is missing');
}
};

Expand All @@ -158,7 +158,7 @@ function processApiExamples() {
outputDir: './demo'
};

const markdownPath = path.join(__dirname, '../docs/partials/apiExamples.md');
const markdownPath = path.join(__dirname, '../docs/partials/api.md');

markdownMagic(markdownPath, config, callback);
}
Expand Down
4 changes: 2 additions & 2 deletions util/auroMigrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function auroMigrate {
echo -e "${GREEN}7.${NC} ${YELLOW}./demo/index.html${NC} copied from ${YELLOW}'${1//\/}'${NC} to ${YELLOW}'${2//\/}/demo/_legacy/index.html${NC}'.\n"
sleep 3
else
command cp "${1//\/}"/docs/partials/demo.md "${2//\/}"/docs/partials/demo.md
command cp "${1//\/}"/docs/partials/index.md "${2//\/}"/docs/partials/index.md
command cp "${1//\/}"/demo/index.html "${2//\/}"/demo/index.html
echo -e "${GREEN}7.${NC} ${YELLOW}./demo${NC} directory copied from ${YELLOW}'${1//\/}'${NC} to ${YELLOW}'${2//\/}'${NC}\n"
sleep 3
Expand Down Expand Up @@ -101,7 +101,7 @@ function auroMigrate {
sleep 1

# close out message
echo -e "\n\nNote: The legacy ${YELLOW}demo.md${NC} and ${YELLOW}package.json${NC} files were maintained.\nBe sure to review these files, manually update with information\nthat needs to be retained and then remove them from the project.\n"
echo -e "\n\nNote: The legacy ${YELLOW}index.md${NC} and ${YELLOW}package.json${NC} files were maintained.\nBe sure to review these files, manually update with information\nthat needs to be retained and then remove them from the project.\n"
echo -e "To see diffs, consider using ${YELLOW}$ vimdiff _legacy/package.json package.json${NC}"
echo -e "\n\nCommitted all changes to ${YELLOW}repoUpgrde${NC} Git branch\n"
echo -e "For any subsequent changes to the ${YELLOW}repoUpgrde${NC}, please\nbe sure to amend to the previous commit.\n"
Expand Down

0 comments on commit d3ec997

Please sign in to comment.