From 65ee885e5bb3ce8ca4241793803a6f08133c0d34 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 02:10:33 +0000 Subject: [PATCH 1/3] Add beta documentation for Python and C++ library docs generation --- fern/products/docs/docs.yml | 4 + .../api-references/generate-library-docs.mdx | 199 ++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 fern/products/docs/pages/api-references/generate-library-docs.mdx diff --git a/fern/products/docs/docs.yml b/fern/products/docs/docs.yml index d1c3d5cf9..fc6eac0a3 100644 --- a/fern/products/docs/docs.yml +++ b/fern/products/docs/docs.yml @@ -273,6 +273,10 @@ navigation: - page: GraphQL Reference path: ./pages/api-references/generate-graphql-ref.mdx slug: generate-graphql-ref + - page: Library documentation + path: ./pages/api-references/generate-library-docs.mdx + slug: generate-library-docs + hidden: true - section: Customization skip-slug: true contents: diff --git a/fern/products/docs/pages/api-references/generate-library-docs.mdx b/fern/products/docs/pages/api-references/generate-library-docs.mdx new file mode 100644 index 000000000..76c16654e --- /dev/null +++ b/fern/products/docs/pages/api-references/generate-library-docs.mdx @@ -0,0 +1,199 @@ +--- +title: Generate library documentation +description: Use Fern Docs to generate documentation for Python and C++ libraries. This beta feature renders classes, methods, and types as an interactive reference. +availability: beta +--- + + + + + Library documentation generation is in beta. The feature and its configuration are subject to change. + + +Fern generates library documentation from Python and C++ source code. Add your library source files to your Fern project and Fern renders classes, methods, types, and modules as an interactive reference. + +## Supported languages + +| Language | Source format | Status | +|----------|--------------|--------| +| Python | `.py` files with docstrings | Beta | +| C++ | Header files (`.h`, `.hpp`) with Doxygen-style comments | Beta | + +## Configuration + + + + +Add your library source files to your `/fern` directory and create a `generators.yml` that references them. + + + + +```yaml generators.yml +api: + specs: + - library: + language: python + root: ./src +``` + +The `root` field points to the directory containing your Python source files. Fern reads classes, functions, and docstrings to generate the reference. + + + + +```yaml generators.yml +api: + specs: + - library: + language: cpp + root: ./include +``` + +The `root` field points to the directory containing your C++ header files. Fern reads classes, functions, and Doxygen-style comments to generate the reference. + + + + + + + +Add `- api: Library Reference` to your navigation in `docs.yml`: + +```yml docs.yml +navigation: + - api: Library Reference +``` + +Fern automatically populates your classes, methods, and types from your library source files. + + + + +Run the following command to preview your documentation locally: + +```bash +fern docs dev +``` + + + + +## Project structure examples + + + + + + + + + + + + + + + + + + +```yaml title="generators.yml" +api: + specs: + - library: + language: python + root: ./src +``` + + + + + + + + + + + + + + + + + + +```yaml title="generators.yml" +api: + specs: + - library: + language: cpp + root: ./include +``` + + + + +### Include more than one library reference + +To include multiple library references in your documentation, use the `api-name` property. The `api-name` corresponds to the folder name containing your library source. + +```yaml title="docs.yml" +navigation: + - api: Plant SDK + api-name: plant-sdk + - api: Garden SDK + api-name: garden-sdk +``` + +## Writing effective source comments + +Fern uses comments in your source code to generate descriptions for classes, methods, and types. + + + + +Use [Google-style docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) for the best results: + +```python +class PlantClient: + """Client for interacting with the Plant API. + + Args: + api_key: Your API key for authentication. + base_url: The base URL of the Plant API. + """ + + def get_plant(self, plant_id: str) -> Plant: + """Retrieve a plant by its ID. + + Args: + plant_id: The unique identifier of the plant. + + Returns: + The requested Plant object. + """ +``` + + + + +Use [Doxygen-style comments](https://www.doxygen.nl/manual/docblocks.html) for the best results: + +```cpp +/** + * @brief Client for interacting with the Plant API. + */ +class PlantClient { +public: + /** + * @brief Retrieve a plant by its ID. + * @param plantId The unique identifier of the plant. + * @return The requested Plant object. + */ + Plant getPlant(const std::string& plantId); +}; +``` + + + From 65d5bd047ec02ed05c808815b2f771b272569877 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 02:14:03 +0000 Subject: [PATCH 2/3] Update library docs to use correct docs.yml libraries schema --- .../api-references/generate-library-docs.mdx | 164 +++++++----------- 1 file changed, 66 insertions(+), 98 deletions(-) diff --git a/fern/products/docs/pages/api-references/generate-library-docs.mdx b/fern/products/docs/pages/api-references/generate-library-docs.mdx index 76c16654e..87ccf8dde 100644 --- a/fern/products/docs/pages/api-references/generate-library-docs.mdx +++ b/fern/products/docs/pages/api-references/generate-library-docs.mdx @@ -10,7 +10,7 @@ availability: beta Library documentation generation is in beta. The feature and its configuration are subject to change. -Fern generates library documentation from Python and C++ source code. Add your library source files to your Fern project and Fern renders classes, methods, types, and modules as an interactive reference. +Fern generates library documentation from Python and C++ source code. Point Fern at a Git repository containing your library, and Fern renders classes, methods, types, and modules as an interactive reference. ## Supported languages @@ -21,129 +21,97 @@ Fern generates library documentation from Python and C++ source code. Add your l ## Configuration - - +Configure library documentation in your `docs.yml` file using the `libraries` key. -Add your library source files to your `/fern` directory and create a `generators.yml` that references them. - - - - -```yaml generators.yml -api: - specs: - - library: - language: python - root: ./src +```yaml title="docs.yml" +libraries: + my-lib: + input: + git: "https://github.com/org/repo" + subpath: "src/sdk" # optional + output: + path: "./pages/reference" + lang: python ``` -The `root` field points to the directory containing your Python source files. Fern reads classes, functions, and docstrings to generate the reference. +### Configuration properties - - + + The language of the library. Supported values: `python`, `cpp`. Routes to the appropriate documentation generator. + -```yaml generators.yml -api: - specs: - - library: - language: cpp - root: ./include -``` + + The Git repository URL containing the library source code. Only `git` input is supported. + -The `root` field points to the directory containing your C++ header files. Fern reads classes, functions, and Doxygen-style comments to generate the reference. + + A subdirectory within the repository to use as the root of the library. For example, `"src/sdk"` if the library code lives in a subdirectory. + - - + + The local path where Fern outputs the generated reference pages. + - - + + Path to a Doxyfile configuration file. C++ only. The file is read from disk and sent as raw content to the backend. + -Add `- api: Library Reference` to your navigation in `docs.yml`: - -```yml docs.yml -navigation: - - api: Library Reference -``` - -Fern automatically populates your classes, methods, and types from your library source files. - - - - -Run the following command to preview your documentation locally: - -```bash -fern docs dev -``` - - - - -## Project structure examples +## Examples - - - - - - - - - - - - - - -```yaml title="generators.yml" -api: - specs: - - library: - language: python - root: ./src +```yaml title="docs.yml" +libraries: + plant-sdk: + input: + git: "https://github.com/my-org/plant-sdk" + subpath: "src/plant" + output: + path: "./pages/plant-reference" + lang: python ``` - - - - - - - - - - - - - - -```yaml title="generators.yml" -api: - specs: - - library: - language: cpp - root: ./include +```yaml title="docs.yml" +libraries: + plant-sdk: + input: + git: "https://github.com/my-org/plant-sdk" + subpath: "include" + output: + path: "./pages/plant-reference" + lang: cpp + config: + doxyfile: "./Doxyfile.txt" ``` -### Include more than one library reference +### Multiple libraries -To include multiple library references in your documentation, use the `api-name` property. The `api-name` corresponds to the folder name containing your library source. +To generate documentation for more than one library, add multiple entries under the `libraries` key: ```yaml title="docs.yml" -navigation: - - api: Plant SDK - api-name: plant-sdk - - api: Garden SDK - api-name: garden-sdk +libraries: + plant-sdk: + input: + git: "https://github.com/my-org/plant-sdk" + output: + path: "./pages/plant-reference" + lang: python + garden-sdk: + input: + git: "https://github.com/my-org/garden-sdk" + subpath: "include" + output: + path: "./pages/garden-reference" + lang: cpp + config: + doxyfile: "./Doxyfile.txt" ``` ## Writing effective source comments From 38721bebb3edc2d3e21f76d19427fc3ce50079b6 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 02:20:52 +0000 Subject: [PATCH 3/3] Simplify param paths, add Doxyfile link, add CLI generation section --- .../api-references/generate-library-docs.mdx | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/fern/products/docs/pages/api-references/generate-library-docs.mdx b/fern/products/docs/pages/api-references/generate-library-docs.mdx index 87ccf8dde..42182a9d6 100644 --- a/fern/products/docs/pages/api-references/generate-library-docs.mdx +++ b/fern/products/docs/pages/api-references/generate-library-docs.mdx @@ -36,24 +36,24 @@ libraries: ### Configuration properties - + The language of the library. Supported values: `python`, `cpp`. Routes to the appropriate documentation generator. - + The Git repository URL containing the library source code. Only `git` input is supported. - + A subdirectory within the repository to use as the root of the library. For example, `"src/sdk"` if the library code lives in a subdirectory. - + The local path where Fern outputs the generated reference pages. - - Path to a Doxyfile configuration file. C++ only. The file is read from disk and sent as raw content to the backend. + + Path to a [Doxyfile](https://www.doxygen.nl/manual/config.html) configuration file. C++ only. The file is read from disk and sent as raw content to the backend. ## Examples @@ -114,6 +114,22 @@ libraries: doxyfile: "./Doxyfile.txt" ``` +## Generate your library docs + +After configuring `docs.yml`, run the following command to generate and preview your documentation: + +```bash +fern docs dev +``` + +This starts a local development server at `http://localhost:3000` where you can view the generated library reference. + +To publish your documentation, run: + +```bash +fern generate --docs +``` + ## Writing effective source comments Fern uses comments in your source code to generate descriptions for classes, methods, and types.