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 include cross-reference links and hierarchical navigation, and are integrated directly into your Fern Docs site.

Configuration

1

Define your libraries in docs.yml

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

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 CLI command to generate MDX files from your library source code:

$fern docs md generate

The command clones the repository, parses the source code, and writes MDX files to the output directory.

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.

4

Preview locally

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

$fern docs dev

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

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
stringRequired

GitHub URL of the repository containing the library source code.

input.subpath
string

Path within the repository to the library source. Useful for monorepos.

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.