-
Notifications
You must be signed in to change notification settings - Fork 710
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
Decouple Renderer
class from HTML output
#2597
Comments
This sounds awesome, and a great way of implementing it. Personally, I would have themes as part of the output options for flexibility. There might be other options relating to specific output types as well. All options in each output could just be passed to the renderer. That way you could have something like: {
"outputs": [
{
"type": "HTML",
"theme": "pastel",
"path": "../docs/html"
},
{
"type": "markdown",
"theme": "github",
"path": "../githubpages"
},
{
"type": "markdown",
"theme": "npm",
"path": "../docs"
},
{
"type": "someplugin/renderer",
"theme": "fire",
"path": "../firedocs"
},
{
"type": "json",
"spaces": 2,
"path": "../docs/docs.json"
}
]
} The alternative would be having multiple typedoc config files, which I guess is also acceptable, but not very DRY |
I ended up deciding that just This isn't perfect as it means that TypeDoc will allow setting options there which will have no effect (options which are handled during conversion) but the additional flexibility is worth it. |
TypeDoc was originally built with the idea of HTML rendering, without consideration for other output types. Later on, TypeDoc gained support for rendering a project to JSON, and later still rendering to markdown (via typedoc-plugin-markdown). It would be neat if TypeDoc could be easily extended via plugins to render documentation in other formats (e.g. LaTeX -> PDF) without hacks.
Today, the markdown plugin hijacks the renderer to support markdown, which prevents users with the plugin activated from producing both HTML and markdown, but has the benefit of letting users just add the plugin, and suddenly get markdown where their HTML was previously being generated. Furthermore, despite markdown rendering not using it, this method still requires that users of it pay the 250+ms price of loading syntax highlighting.
The way it seems that this ought to work is that TypeDoc's renderer shouldn't care about HTML/JSON/Markdown/Tex/whatever, but instead deal with an interface which applies to all of them.
For a first cut at this, I propose:
TypeDoc's CLI will move from calling
app.generateJson
/app.generateDocs
to callingapp.renderer.writeOutputs
.The
--out
option will be replaced with a--html
option. The--html
and--json
options will be added as "output shortcuts" for CLI convenience:But users desiring more flexibility can use the new
outputs
option, even to render multiple times to different paths!The good:
The bad:
OutputOptions
need to have an optionaltheme
key too? That'd be unfortunate if so, as some outputs (e.g. JSON) likely won't ever have themes. Is each theme a new output type? I guess that works, a minimal html theme could define--htmlMinimal
as an output shortcut... it's kind of weird that minor html theme tweaks require a brand new output, but implementing it is still just extending two classes, so...I did some prototyping of this nine (nine?! what? how?!) months ago over on the output-rework branch. Now that 0.26 is about to release, I'm looking at it again now for 0.27, which I plan on being a smaller release, hopefully mostly focused on some rendering enhancements and this. I'll probably look at getting that rebased on master next weekend.
Ref: #2288 (comment)
The text was updated successfully, but these errors were encountered: