Fantastic resource π
Documentation as Code (Docs as Code) refers to a philosophy that you should be writing documentation with the same tools as code.
Source: Write the Docs
π Issue Trackers
π³ Version Control (git)
π€ Plain Text Markup
(Markdown, reStructuredText, Asciidoc)
π¬ Code Reviews
β Automated Tests
Align tracking the work of documentation with code. (have it live in the same queue)
Enable docs and code to live in same changeset
(like your tests)
Enable concurrent development branches
π Enable all the features of version control for your documentation!
Enable all the features of your code editors in documentation
(compare, find/replace, track in version control)
π Many editors with preview mode for Markdown as you edit!
Enable discussions with code using the same toolchain (line-by-line comments, suggestions they can apply, CODEOWNERS)
Enable static analysis tests on documentation (status checks on pull requests)
π Islands of documentation
(MediaWiki, Confluence, Office 365, READMEs, GitHub Pages)
π Excessive documentation decay
(possibly caused by islands)
π Searchability challenges
π€·ββοΈ Different process for maintaining (vs. with code)
π Lack of trust on the content
π Islands of documentation
(MediaWiki, Confluence, Office 365, READMEs, GitHub Pages)
π Documentation decay due to islands
π Searchability challenges
π Islands of documentation
(MediaWiki, Confluence, Office 365, READMEs, GitHub Pages)
π Documentation decay due to islands
π Searchability challenges
π A centralized build system for documentation that can enable content through a common convention
π€·ββοΈ Different process for maintaining (vs. with code)
π€·ββοΈ Different process for maintaining (vs. with code)
π§° Enable documentation to exist closer to the code and toolchain
π Lack of trust on the content
π Lack of trust on the content
πͺ Make it easy for anyone to contribute
help them along the way, like DocDays!
But, not everyone has GitHub access…
or knows Markdown.
π€·ββοΈ
Ensure approach aligns with strategy for expected toolchain access
(GitHub Enterprise)
Illustrate through examples that if you know text,
you can write Markdown
Majority of contributions = textual content, β formatting
π€ Markdown: Authoring
βοΈ Hugo: Generating
π Docsy: Theming
β‘οΈ GitHub Actions: Building
π GitHub Pages: Serving
Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents. Created by John Gruber in 2004, Markdown is now one of the worldβs most popular markup languages.
Source: The Markdown Guide
Great resource π
The worldβs fastest framework for building websites
π¦ Shortcodes
Powerful way to extend beyond Markdown with reusable code blocks
πͺ΄ Multiple Formats
Hugo allows you to output your content in multiple formats...like this presentation
π¦₯ Flexible
Build different types of content (menus, diagrams) to make a rich website out of Markdown
β‘οΈ Speed
At < 1 ms per page, the average site builds in less than a second
Generate API documentation from your OpenAPI (Swagger) specifications.
{{< swaggerui src="/openapi/petstore.yaml" >}}
```mermaid
graph LR
Start --> Need{"Do I need diagrams"}
Need -- No --> Off["Set params.mermaid.enable = false"]
Need -- Yes --> HaveFun["Great! Enjoy!"]
```
Build your docs!
Include in .github/workflows/gh-pages.yaml
file.
name: github pages
on:
push:
branches:
- main
pull_request:
jobs:
deploy:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive # Fetch the Docsy theme
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
# Can pin to a specific version if needed, ex:
# hugo-version: '0.79.1'
hugo-version: 'latest'
extended: true
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: hugo
env:
HUGO_ENV: production
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
Test your docs (spellcheck)!
Include in .github/workflows/validation.yaml
file.
name: validation
on:
push:
branches:
- main
pull_request:
jobs:
spell-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Check out the code
- uses: actions/setup-node@v1
name: Run spell check
with:
node-version: "12"
- run: npm install -g cspell
- run: cspell lint --config .github/cspell.json "content/**/*.md"
β Enforce your tests in pull requests
βοΈ GitHub Actions build content on PRs and main
π§ Generate and store static content for serving
https://cchesser.github.io/docs-as-code/
βοΈ Try the Edit this Page link to make a change via a PR
βοΈ See build process on pull request and preview
π Definition and approach
π Background of how others have approached it
β€οΈ Benefits and how it lends to common problems in documentation
π Examples with: Markdown, Hugo, Docsy, GitHub, GitHub Actions, GitHub Pages