Static Documentation and Github
See the source for this github page at: https://github.com/edgarroman/techtalk-mkdocs
Github Pages
- Ability to host any static files in a github repository.
- Similar to S3 but free
- Several Options:
- Use
gh-pages
branch - Use
master
branch - Use
docs
directory onmaster
branch - URL format is:
https://<username or organization>.github.io/<project name>
- Allowed to have custom domain easily - just point your DNS
- Can put stuff at
by creating a project named after the organization or user.https://<username or organization>.github.io/
Basics
Markdown
- Defacto Standard
- But not really standardized (e.g. Github-flavored Markdown)
- Learn it
- Quick Examples
- https://jbt.github.io/markdown-editor/
- https://stackedit.io/editor
Editors
- https://jbt.github.io/markdown-editor/
- https://stackedit.io/editor
- Macdown
- VSCode
- Plugins for Sublime, etc
- Infinite others
Approaches
- Write Markdown source, compile/build it, upload HTML
- Write Markdown source, upload raw, have JS render on the fly
- Some critical of this approach
- Only found one realistic framework that is a bit old: Flatdoc
Will be focusing on option 1 above
How it works (option 1)
One-time setup of github pages (Easiest to create the gh-pages
branch. Autodetected by github). Then:
- Write source material in markdown
- Check source material into the
master
branch - Run a build on the source material to render material
- Check in rendered material into the
gh-pages
branch - Rinse, Repeat
If you're really cool, then you will have a CI system do your build for you. But if you're cheap (like me), just do it manually (Lazy! SAD!)
Frameworks
Tons Pretty good list: https://www.staticgen.com/
Pretty much any language you want: Python, .NET, Go, PHP - even non languages like Javascript!
- Some are better for blogs: Have fancy tag clouds and 'most recent' widgets
- Some are just straight up pages: More general documentation
- Some are focused on API: But swagger would probably be a better choice
Criteria for this talk
- General Static Page (non-blog)
- Minimal install overhead (e.g. only Python)
- Good Documentation
- Reasonably good looking output
- Simple
Best frameworks
Others:
- Cactus - Bad docs
- Sphinx - Complicated
- Gitbook - Corporate pig dogs
- Jekyll - Don't know how to use ruby
- Hyde - Terrible documentation
MKDocs Walkthrough
- Create Repo
- Install mkdocs
virtualenv ve source ve/bin/activate pip install mkdocs
- Init the mkdocs project
mkdocs new .
- Customize mkdocs.yml
site_name: Mkdocs overview pages: - Home: 'README.md'
- Add / Edit pages
- Run local server
mkdocs serve
- Edit and revise
- Commit and push source to github
- Deploy to gh-pages
mkdocs gh-deploy
- Profit
Advanced
Themes
site_name: Mkdocs overview
pages:
- Home: 'README.md'
theme: readthedocs
Extensions
-
Any pyMdown extensions
pip install pymdown-extensions
site_name: Mkdocs overview
pages:
- Home: 'README.md'
markdown_extensions:
- pymdownx.superfences