-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate documentation and add loggers
- Loading branch information
1 parent
46afa88
commit 9510b42
Showing
10 changed files
with
1,012 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"include": ["**/*.vue"], | ||
"exclude": [], | ||
"outDir": "test-website" | ||
"outDir": "test-website", | ||
"markdownDir": "components" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = [ | ||
{ | ||
type: 'list', | ||
name: 'genType', | ||
message: 'Select the target to generate', | ||
default: 'docute', | ||
choices: [ | ||
{ | ||
name: 'Docute - The fastest way to create a documentation site for your project.', | ||
value: 'docute' | ||
}, | ||
{ | ||
name: 'Only markdown.', | ||
value: 'markdown' | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const sao = require('sao') | ||
const path = require('path') | ||
const lib = require('./index') | ||
const logger = require('log-horizon').create() | ||
|
||
module.exports = async (config) => { | ||
const { | ||
outDir = 'website' | ||
} = config | ||
|
||
try { | ||
const componentNamesPromise = await lib(config) | ||
const componentNames = await Promise.all(componentNamesPromise) | ||
logger.progress('Start generating...') | ||
await sao({ | ||
template: path.resolve(__dirname, './templates/docute'), | ||
targetPath: path.resolve(outDir), | ||
configOptions: { | ||
componentNames, | ||
markdownDir: config.markdownDir | ||
} | ||
}) | ||
logger.success('Generated successfully') | ||
} catch (err) { | ||
console.error(err.name === 'SAOError' ? err.message : err.stack) | ||
process.exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = (options) => { | ||
return { | ||
prompts: { | ||
title: { | ||
type: 'input', | ||
message: 'Sidbar title:', | ||
default: 'Components' | ||
} | ||
}, | ||
data (answers) { | ||
return { | ||
title: answers.title, | ||
componentNames: options.componentNames, | ||
markdownDir: options.markdownDir | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<title>My Docs</title> | ||
<link rel="stylesheet" href="https://unpkg.com/docute@4/dist/docute.css"> | ||
</head> | ||
<body> | ||
<div id="docute"></div> | ||
<script src="https://unpkg.com/docute@4/dist/docute.js"></script> | ||
<script> | ||
new Docute({ | ||
target: '#docute', | ||
sidebar: [ | ||
{ | ||
title: '<%= title %>', | ||
links: [ | ||
<% for (var i = 0; i < componentNames.length; i++) { %> | ||
{ | ||
title: '<%= componentNames[i] %>', | ||
link: '/<%= markdownDir %>/<%= componentNames[i] %>' | ||
}<% if (i !== componentNames.length - 1) { %>,<% } %> | ||
<% } %> | ||
] | ||
} | ||
] | ||
}) | ||
</script> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.