Skip to main content

Dart handler for mkdocstrings

Project description

mkdocstrings-dart

License

A Dart handler for mkdocstrings, bringing beautiful, automatic API documentation to Dart packages in MkDocs.

Powered by dartdoc_json, it extracts doc comments, signatures, parameters, return types, and source code from your Dart libraries — no extra configuration needed.

Features

  • Renders classes, constructors, methods, getters/setters
  • Parameter tables with names, types, and defaults
    (Parameter descriptions appear in the main method docstring)
  • Return type display
  • Collapsible source code with Dart syntax highlighting
  • Auto-detects your package name from pubspec.yaml
  • Supports both ::: package.Class and ::: Class identifiers
  • Respects paths, exclude_files, and show_source options
  • Modern, wide, responsive styling

Installation

pip install mkdocstrings-dart
dart pub global activate dartdoc_json

Note: dartdoc_json is required to parse Dart source. It's lightweight and uses the official Dart analyzer.

Usage

Note: When using mkdocstrings-dart alongside other handlers (e.g., the default Python handler), you must explicitly set the default handler if you want Dart to be used for unmarked ::: blocks, otherwise define the handler with each block definition.

In your mkdocs.yml:

plugins:
  - mkdocstrings:
      default_handler: dart   # <- Required if you want ::: Identifier to use Dart by default
      handlers:
        dart:
          options:
            paths: ["lib"]                # Default: ["lib"]
            show_source: true             # Show collapsible source code
            exclude_files: ["curo.dart"]  # Optional: skip barrel files

Options

Option Type Default Description
paths list[str] ["lib"] Directories to scan for .dart files
show_source bool true Show source code in a collapsible panel
exclude_files list[str] [] Basenames of files to skip (e.g., barrel files)
heading_level int 2 Starting heading level for rendered docs

Then in your Markdown files:

# Calculator API

::: <package-name>.Calculator
# or simply
::: Calculator

Rendered Example

Below is exactly how the above ::: Calculator markdown will appear in your final HTML documentation site:

Screenshot of rendered Dart docs using the included example

Development

# Editable install
pip install -e .
dart pub global activate dartdoc_json
mkdocs serve

Roadmap

  • Support for library-level overviews
  • Cross-references between classes
  • Better handling of generics and annotations
  • Material for MkDocs theme integration tweaks

Credits

Built with inspiration from the official mkdocstrings Python handler and powered by the excellent dartdoc_json tool.

Made with :heart: for the Dart community.

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

mkdocstrings_dart-0.1.0.tar.gz (326.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocstrings_dart-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file mkdocstrings_dart-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocstrings_dart-0.1.0.tar.gz
  • Upload date:
  • Size: 326.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mkdocstrings_dart-0.1.0.tar.gz
Algorithm Hash digest
SHA256 909cb6323a46c8d798fe73a8f413f5bcb65b3daab238aa2c672604ca16a6ae16
MD5 30a4681e289e3acc6a389b174d3fa271
BLAKE2b-256 9238649dde29a9382fc9f0c427dae9d7a131ff092070c8229008587bfdc0f60b

See more details on using hashes here.

File details

Details for the file mkdocstrings_dart-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocstrings_dart-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6169cc63727ef149e087dad661aab52f7526b22304773fbfada20c3cdc5c97d7
MD5 2a566a327fdf6b485382f711e5798243
BLAKE2b-256 692b2bc9b28dcf88589362ddbd737c56a72cb9c8336c439c090af6b3d3946361

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page