Provide option to incorporate directory of Markdown files into generated HTML documentation #58
Description
As suggested by @MaxDesiatov in #57:
It would be great if there was an option not just to include README.md, but a given directory hierarchy of multiple markdown files that provide extended documentation: tutorials, guidelines, license, code of conduct etc.
Scoping the feature request a bit, I think a good first step would be to add a new, optional parameter to the generate
command to specify a directory of Markdown files (Documentation
by default) to be rendered alongside the generated symbol reference docs.
For example, given the following project structure:
.
├── Documentation
│ ├── Advanced-Usage.md
│ ├── FAQ.md
│ └── Getting-Started.md
└── Sources
swift doc generate --format html
would produce three "Guide" pages for "Advanced Usage", "FAQ", and "Getting Started".
My only hesitation here is that it gets us into the business of static site generation more generally (a corollary of Zawinski's Law. To that end, I'm unsure on whether to should support any form of YAML front matter...
Edit: Actually, you know what? I'm putting my foot down: No YAML front matter! I know of a better way that doesn't add another dependency or threaten to go down a slippery slope of supporting TOML / JSON / whatever front matter — I randomly came across it in this Hugo issue thread:
@bep: This is just me thinking out loud during Christmas. I kind of like the simplicity of it. The idea is to use SGML Processing Instructions as a way to pass parameters to the new and shiny render hooks in Hugo (images and links).
So instead of this:
---
title: Getting Started
---
Reprehenderit culpa qui enim elit sunt laborum do occaecat nostrud exercitation enim ex...
You do something like this (final spelling TBD):
Reprehenderit culpa qui enim elit sunt laborum do occaecat nostrud exercitation enim ex...
<?swiftdoc title="Getting Started" ?>
Processing Instructions aren't rendered by default, and would be otherwise invisible. And unlike front matter, it can appear anywhere in the document.
If we scope this feature to Markdown files with optional PI for customization, I think that strikes a good balance for a "batteries included" output, with the option to further customize using a dedicated static site generator based on the CommonMark output.