-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config and Plugin Support #14
Conversation
…to feat/docs-config
app.js
Outdated
try { | ||
util.compileDocs(user, repo).then(() => { | ||
util.serveDocs(app, user, repo); | ||
res.send(`Successfully Compiled Docs! View them at /${user}/${repo}`); | ||
}); | ||
} catch (error) { | ||
res.send( | ||
`Oops. We couldn't render these docs. Check your config if you have one and try again!` | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does compileDocs
have an error handler? That would be better than try / catch
{ | ||
"description": "Description", | ||
"plugins": [], | ||
"gaCode": "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request description says this isn'' required right? Is this an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the config.json
here is just the list of supported keys that can be used
try { | ||
Object.keys(config).forEach((key) => { | ||
mainConfig[`${key}`] = config[key]; | ||
}); | ||
|
||
mainConfig.enablePlugins = false; | ||
if (mainConfig.plugins.length > 0) { | ||
mainConfig.enablePlugins = true; | ||
} | ||
|
||
if (mainConfig.enablePlugins) { | ||
const pluginConfig = plugins.addPlugins(mainConfig.plugins); | ||
mainConfig.plugins = pluginConfig; | ||
} | ||
|
||
const htmlData = docsify.generateHtmlWithConfig(mainConfig); | ||
|
||
fs.writeFileSync(`./docs/${user}-${repo}/README.md`, readmeData, function ( | ||
err | ||
) { | ||
if (err) throw err; | ||
console.log("Generated ReadMe!"); | ||
}); | ||
|
||
fs.writeFileSync(`./docs/${user}-${repo}/index.html`, htmlData, function ( | ||
err | ||
) { | ||
if (err) throw err; | ||
console.log("Generated HTML!"); | ||
}); | ||
} catch (error) { | ||
writeDocsWithDefaultConfig(user, repo, readmeData); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try/catch
is not a best practice.
https://softwareengineering.stackexchange.com/questions/144326/try-catch-in-javascript-isnt-it-a-good-practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, interesting read. Will look more into error handling with callback functions. Future refactor!!
This PR includes:
Config
/:user/:repo
for a.fastdocs.json
config file. This allows fastdocs to know which plugins to add when rendering the docs.Current Config:
gaCode
is only required whengoogle-analytics
is added to theplugins
arrayPlugins
docsify-copy-code
: Adds a "Copy to Clipboard" next to code blocksfull-text-search
: Adds a search bar on the top of the sidebar to quickly search docsgoogle-analytics
: Support for google analyticsgaCode
on the config.emoji
: Renders emoji's in your documentation. (Ex::100:
would render to 💯)zoom-image
: Adds subtle zooming to images cursor is hovering