A Nim handler for mkdocstrings
Project description
mkdocstrings-nim
Generate API documentation for your Nim projects.
mkdocstrings-nim extracts documentation from Nim source files using the Nim compiler's AST, including module docstrings, procedure signatures, parameter types, return types, and pragma annotations. It renders the documentation as HTML using MkDocs and mkdocstrings.
Full Documentation | Changelog
Quick Start
This guide gets you from zero to a running documentation server for your Nim project.
Prerequisites
- Nim compiler installed and in PATH (install Nim)
- Python 3.9+ (install Python)
1. Install the tools
pip install mkdocs mkdocs-material mkdocstrings-nim
2. Create mkdocs.yml
In your Nim project root, create mkdocs.yml:
site_name: My Nim Project
theme:
name: material
plugins:
- search
- mkdocstrings:
handlers:
nim:
paths: [src] # Where your .nim files are
options:
show_source: true
docstring_style: rst
3. Create your docs
Create a docs/ directory with an index.md:
mkdir docs
docs/index.md:
# My Nim Project
Welcome to my project documentation.
## API Reference
::: mymodule
The ::: mymodule directive tells mkdocstrings to extract and render documentation from src/mymodule.nim.
4. Run the docs server
mkdocs serve
Open http://127.0.0.1:8000 to see your documentation.
5. Build for deployment
mkdocs build
This creates a site/ directory with static HTML ready to deploy to GitHub Pages, Netlify, or any static host.
Writing Nim Docstrings
Use ## comments to document your Nim code:
## This module provides greeting utilities.
proc greet*(name: string): string =
## Greet someone by name.
##
## :param name: The name to greet
## :returns: A greeting message
result = "Hello, " & name & "!"
type
Config* = object
## Configuration for the greeter.
prefix*: string ## The greeting prefix
suffix*: string ## The greeting suffix
Supported docstring styles: rst (default), google, numpy, epydoc.
Configuration Options
Configure in mkdocs.yml under plugins > mkdocstrings > handlers > nim > options:
| Option | Default | Description |
|---|---|---|
paths |
["src"] |
Search paths for Nim source files |
docstring_style |
"rst" |
Docstring format: rst, google, numpy, epydoc, auto |
show_source |
true |
Show source file and line numbers |
show_signature |
true |
Show full procedure signatures |
show_pragmas |
true |
Show pragma annotations like {.raises.} |
show_private |
false |
Include non-exported (private) symbols |
heading_level |
2 |
Starting heading level for entries |
source_url |
null |
Repository URL for source links (e.g., https://github.com/user/repo) |
See the full documentation for more details.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocstrings_nim-0.1.2.tar.gz.
File metadata
- Download URL: mkdocstrings_nim-0.1.2.tar.gz
- Upload date:
- Size: 32.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c33c8eb2b414a6a3cb9260d8c110afc797b3154c033085e37d9fad7dc533f39d
|
|
| MD5 |
65628e9ac763181b3f649c41476d813f
|
|
| BLAKE2b-256 |
297f8c81e918591473f14b2575ea93db292d973bd5dee5b0f8a3e91b8176259f
|
Provenance
The following attestation bundles were made for mkdocstrings_nim-0.1.2.tar.gz:
Publisher:
publish.yml on elijahr/mkdocstrings-nim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocstrings_nim-0.1.2.tar.gz -
Subject digest:
c33c8eb2b414a6a3cb9260d8c110afc797b3154c033085e37d9fad7dc533f39d - Sigstore transparency entry: 737886563
- Sigstore integration time:
-
Permalink:
elijahr/mkdocstrings-nim@7b80340160964a2336c2d8ae0c57ddef93960572 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/elijahr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b80340160964a2336c2d8ae0c57ddef93960572 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mkdocstrings_nim-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mkdocstrings_nim-0.1.2-py3-none-any.whl
- Upload date:
- Size: 79.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbeed5dd3ff5a3e614a6651a8e56dd4786f144e8fc5103032d3a249de0b44d36
|
|
| MD5 |
723cda64a3c33dc0416bde58099c5356
|
|
| BLAKE2b-256 |
7e690821ea2545073b1a38ab999f4fd8e72ec97a4e57e8a057790ae5cb560155
|
Provenance
The following attestation bundles were made for mkdocstrings_nim-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on elijahr/mkdocstrings-nim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocstrings_nim-0.1.2-py3-none-any.whl -
Subject digest:
fbeed5dd3ff5a3e614a6651a8e56dd4786f144e8fc5103032d3a249de0b44d36 - Sigstore transparency entry: 737886566
- Sigstore integration time:
-
Permalink:
elijahr/mkdocstrings-nim@7b80340160964a2336c2d8ae0c57ddef93960572 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/elijahr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b80340160964a2336c2d8ae0c57ddef93960572 -
Trigger Event:
push
-
Statement type: