Code Examples¶
This page demonstrates code blocks with syntax highlighting, line numbers, and copy-to-clipboard functionality in Java, YAML, and Bash. It also includes code tabs and Mermaid diagrams.
Java Example¶
The following Java snippet shows a simple service class:
YAML Example¶
Configuration for a CI pipeline:
Bash Example¶
Build and serve locally:
Language tabs¶
Use tabs to present equivalent snippets in multiple languages while saving vertical space. MkDocs supports this via the pymdownx.tabbed extension (already enabled in mkdocs.yml).
Same workflow in different formats:
Code tabs (shells)¶
Compare the same command across shells:
Mermaid Diagrams¶
Sequence Diagram¶
sequenceDiagram
participant User
participant MkDocs
participant GitHub
User->>MkDocs: mkdocs build
MkDocs->>MkDocs: Render Markdown
MkDocs->>User: site/ output
User->>GitHub: Push to main
GitHub->>GitHub: Run deploy workflow
GitHub->>User: Live at GitHub Pages Class Diagram¶
classDiagram
class MkDocs {
+build()
+serve()
}
class Material {
+themes
+search
}
MkDocs --> Material : uses Flowchart¶
Doc build pipeline:
flowchart LR
subgraph Source
MD[Markdown Files]
Config[mkdocs.yml Configuration]
end
subgraph Build
MkDocs[MkDocs Build]
end
subgraph Output
HTML[Static HTML Site]
Site[GitHub Pages]
end
MD --> MkDocs
Config --> MkDocs
MkDocs --> HTML
HTML --> Site Tables and Admonitions¶
Feature Support¶
| Feature | Supported |
|---|---|
| Markdown | Yes |
| Search | Yes |
| PDF Export | Yes |
| Dead link detection | Yes (via mkdocs-linkcheck) |
Pro Tip
Use mkdocs serve during development. Changes to Markdown files trigger an automatic reload.
PDF Generation
PDF export requires WeasyPrint and system dependencies (cairo, Pango). See the project README in the repository for installation details.
Internal Links
Link to Getting Started or a specific section: Installation.