Library docs generator Beta

View as Markdown

The library docs generator parses your Python or C++ library source code and generates MDX documentation pages for modules, classes, functions, methods, and parameters. Generated pages are added to your Fern Docs site with hierarchical navigation.

Cross-links are automatic. When a fully qualified identifier appears in a code block — for example, in a class signature or type annotation — the generator links it to the page documenting that symbol, so readers can jump straight to the definition.

Configuration

1

Define your libraries in docs.yml

Add a libraries entry to your docs.yml file. Each library needs an input source, an output.path (where generated MDX files are written), and a lang (python or cpp).

The input source can be a git URL, parsed remotely on Fern’s servers, or a local path, parsed on your machine with the --local flag. Local parsing is useful for iterating on documentation without pushing to a remote repository, and doesn’t require you to be logged in to Fern.

docs.yml
1libraries:
2 plant-core:
3 input:
4 git: https://github.com/acme/plant-core-cpp # repository URL
5 subpath: packages/plant-core # optional, for monorepos
6 output:
7 path: ./static/plant-core-docs # relative to fern/ directory
8 lang: cpp # python or cpp
9 config:
10 doxyfile: ./Doxyfile # optional, C++ only

You can define multiple libraries in the same file.

2

Add to navigation

Point a folder: entry in your navigation at the same directory you set as output.path. Fern discovers every MDX file in that folder and mirrors its subfolder structure into sidebar sections.

docs.yml
1navigation:
2 - section: Getting started
3 contents:
4 - page: Overview
5 path: ./pages/overview.mdx
6 - section: Plant SDK Reference
7 contents:
8 - folder: ./static/plant-sdk-docs
3

Generate the library docs

Run the fern docs md generate command to generate MDX files from your library source code:

$fern docs md generate

The command sends the repository URL to Fern’s servers for parsing.

If you have multiple libraries configured, fern docs md generate processes all libraries in parallel. Use --library plant-sdk to generate docs for a specific library only.

The generated docs form a navigation section with pages for each module, class, function, and type in your library.

4

Preview locally

Run the local development server to see your library docs alongside the rest of your site:

$fern docs dev

You can also generate a shareable preview URL:

$fern generate --docs --preview
5

Publish

Publish your library documentation:

$fern generate --docs

You can define and reference multiple libraries in the same docs.yml:

docs.yml
1libraries:
2 plant-python-sdk:
3 input:
4 git: https://github.com/acme/plant-sdk-python
5 output:
6 path: ./static/python-docs
7 lang: python
8 plant-core:
9 input:
10 git: https://github.com/acme/plant-core-cpp
11 output:
12 path: ./static/cpp-docs
13 lang: cpp
14
15navigation:
16 - section: Python SDK Reference
17 contents:
18 - folder: ./static/python-docs
19 - section: C++ API Reference
20 contents:
21 - folder: ./static/cpp-docs

Customize generated docs (optional)

You can reorganize the output directory to restructure the sidebar navigation. Move, rename, or nest files and subfolders, and Fern picks up the new layout on the next fern docs dev or publish.

For example, splitting ./static/plant-sdk-docs into getting-started/ and reference/ subfolders produces two sidebar sections:

docs.yml
1navigation:
2 - section: Plant SDK Reference
3 contents:
4 - folder: ./static/plant-sdk-docs/getting-started
5 title: Getting started
6 - folder: ./static/plant-sdk-docs/reference
7 title: API reference

You can also edit page content by modifying the MDX files directly — generated pages are standard MDX, so you can add prose, examples, callouts, or any component. Re-running fern docs md generate overwrites everything in output.path, so commit your customizations first, and keep hand-edited pages outside the output directory if you plan to regenerate.

Configuration reference

input.git
string

GitHub URL of the repository containing the library source code. Parsed remotely on Fern’s servers. Mutually exclusive with input.path.

input.subpath
string

Path within the repository to the library source. Only valid with input.git. Useful for monorepos.

input.path
string

Local filesystem path to the library source, relative to the fern/ directory. Requires --local flag. Mutually exclusive with input.git.

output.path
stringRequired

Directory where the generated MDX files are written, relative to the fern/ directory.

lang
stringRequired

The language of the library. Supported values: python, cpp.

config.doxyfile
string

Path to a custom Doxyfile. C++ only. For local generation, the Doxyfile’s input paths are resolved relative to the input.path directory.