Library docs generator Beta

View as Markdown

The library docs generator parses your Python or C++ library source code to produce 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, an output directory, and a lang (language).

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

Reference the generated pages in your navigation using folder: directives. The folder: directive discovers all MDX files in the specified directory and creates navigation sections based on the subdirectory structure.

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

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.