Skip to content

Commit

Permalink
docs(11ty)[WIP]: generate API docs as json
Browse files Browse the repository at this point in the history
  • Loading branch information
ffoodd committed Mar 3, 2022
1 parent 4ea9a83 commit 62a5f9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions a11y.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const DIRECTORIES = {
},
api: {
input: './sass/utils/',
output: './src/_data/api/'
output: './src/_data/sass/'
},
assets: {
css: {
Expand Down Expand Up @@ -101,7 +101,7 @@ const processSassDocumentation = file => {
)
}

/*const processApiDocumentation = file => {
const processApiDocumentation = file => {
const inputFileExtension = path.extname(file)
const inputFilename = path.basename(file, inputFileExtension)
const excludeFiles = ['_all']
Expand All @@ -123,12 +123,8 @@ const processSassDocumentation = file => {
fs.mkdirSync(DIRECTORIES.api.output)
}

// Write Eleventy data files
fs.writeFileSync(
`${DIRECTORIES.api.output}/${inputFilename.replace('_', '')}.json`,
JSON.stringify(comments, null, 2)
)
}*/
return JSON.stringify(comments, null, 2)
}

const parseSassComment = comment => {
// Remove CSS comments syntax
Expand Down Expand Up @@ -178,9 +174,16 @@ const generateJsonDocumentation = () => {
processSassDocumentation(DIRECTORIES.sass.input + file)
})

fs.readdirSync(DIRECTORIES.api.input).forEach(file => {
processSassDocumentation(DIRECTORIES.api.input + file)
let contentAPI = {}
fs.readdirSync(DIRECTORIES.api.input).forEach((file, index) => {
contentAPI[index] = processApiDocumentation(DIRECTORIES.api.input + file)
})

// Write Eleventy data files
fs.writeFileSync(
`${DIRECTORIES.api.output}/api.json`,
JSON.stringify(contentAPI, null, 2)
)
}

module.exports = function () {
Expand Down
2 changes: 1 addition & 1 deletion src/_data/themes.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
},
{
"title": "API",
"theme": "variables"
"theme": "api"
}
]

0 comments on commit 62a5f9c

Please sign in to comment.