-
Notifications
You must be signed in to change notification settings - Fork 7
Add library docs page #3840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Add library docs page #3840
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
fern/products/docs/pages/api-references/library-docs.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| --- | ||
| title: Library Docs | ||
| subtitle: Generate reference documentation for your client libraries directly from source code. | ||
| --- | ||
|
|
||
| <Markdown src="/snippets/agent-directive.mdx"/> | ||
|
|
||
| Fern can generate reference documentation for your client libraries (e.g., Python SDKs) directly from source code. Library docs are auto-generated MDX pages that document modules, classes, methods, and parameters — rendered as first-class sections in your docs site. | ||
|
|
||
| <Note> | ||
| Library docs is currently in **beta**. Python and C++ are supported today. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </Note> | ||
|
|
||
| ## How it works | ||
|
|
||
| 1. You define a `libraries` configuration in your `docs.yml` pointing to a Git repository containing your library source code. | ||
| 2. Running `fern docs md generate` parses the source code and generates MDX files with full navigation. | ||
| 3. You reference the library in your navigation using the `library` navigation item, and Fern renders the generated pages as a section in your docs. | ||
|
|
||
| ## Configuration | ||
|
|
||
| <Steps> | ||
| <Step title="Define your library 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). | ||
|
|
||
| ```yaml title="docs.yml" {1-7} | ||
| libraries: | ||
| my-python-sdk: | ||
| input: | ||
| git: https://github.com/acme/sdk-python | ||
| subpath: src/sdk # optional: path within the repo | ||
| output: | ||
| path: ./static/sdk-docs | ||
| lang: python | ||
| ``` | ||
|
|
||
| The `input` can be a Git repository: | ||
|
|
||
| | Property | Description | Required | | ||
| |-----------|----------------------------------------------------------|----------| | ||
| | `git` | GitHub URL to the repository containing the library source code. | Yes | | ||
| | `subpath` | Path within the repository to the library source. | No | | ||
|
|
||
| The `output` specifies where generated MDX files are written: | ||
|
|
||
| | Property | Description | Required | | ||
| |----------|------------------------------------------------|----------| | ||
| | `path` | The output directory for generated MDX files. | Yes | | ||
|
|
||
| </Step> | ||
| <Step title="Generate library documentation"> | ||
|
|
||
| Run the generation command to parse your library source code and produce MDX files: | ||
|
|
||
| ```bash | ||
| fern docs md generate | ||
| ``` | ||
|
|
||
| This generates MDX files and a `_navigation.yml` file in the configured output directory. The generated files document all public modules, classes, methods, and their parameters. | ||
|
|
||
| </Step> | ||
| <Step title="Add the library to your navigation"> | ||
|
|
||
| Reference the library in your `docs.yml` navigation using the `library` key. The value must match a key defined in your `libraries` section. | ||
|
|
||
| ```yaml title="docs.yml" {10-11} | ||
| libraries: | ||
| my-python-sdk: | ||
| input: | ||
| git: https://github.com/acme/sdk-python | ||
| output: | ||
| path: ./static/sdk-docs | ||
| lang: python | ||
|
|
||
| navigation: | ||
| - library: my-python-sdk | ||
| title: Python SDK Reference # optional: override display title | ||
| slug: python-sdk # optional: override URL slug | ||
| ``` | ||
|
|
||
| Fern reads the generated `_navigation.yml` and MDX files from the output directory and renders them as a full navigation section in your docs. | ||
|
|
||
| </Step> | ||
| <Step title="Preview and publish"> | ||
|
|
||
| Preview your docs locally with: | ||
|
|
||
| ```bash | ||
| fern docs dev | ||
| ``` | ||
|
|
||
| When ready, publish with: | ||
|
|
||
| ```bash | ||
| fern generate --docs | ||
| ``` | ||
|
|
||
| </Step> | ||
| </Steps> | ||
|
|
||
| ## Supported languages | ||
|
|
||
| | Language | Status | | ||
| |----------|--------| | ||
| | Python | Beta | | ||
| | C++ | Beta | | ||
|
|
||
| ## Configuration reference | ||
|
|
||
| ### `libraries` (top-level) | ||
|
|
||
| The `libraries` key is a map where each entry defines a library to generate docs for. | ||
|
|
||
| ```yaml title="docs.yml" | ||
| libraries: | ||
| <library-name>: | ||
| input: | ||
| git: <github-url> | ||
| subpath: <optional-path> # path within the repo | ||
| output: | ||
| path: <output-directory> # where MDX files are written | ||
| lang: <language> # python or cpp | ||
| ``` | ||
|
|
||
| ### `library` (navigation item) | ||
|
|
||
| The `library` navigation item references a library defined in the `libraries` section. | ||
|
|
||
| ```yaml title="docs.yml" | ||
| navigation: | ||
| - library: <library-name> # must match a key in `libraries` | ||
| title: <optional-title> # override display title | ||
| slug: <optional-slug> # override URL slug | ||
| ``` | ||
|
|
||
| ## Multiple libraries | ||
|
|
||
| You can define multiple libraries and include them in your navigation: | ||
|
|
||
| ```yaml title="docs.yml" | ||
| libraries: | ||
| python-sdk: | ||
| input: | ||
| git: https://github.com/acme/sdk-python | ||
| output: | ||
| path: ./static/python-sdk-docs | ||
| lang: python | ||
| cpp-sdk: | ||
| input: | ||
| git: https://github.com/acme/sdk-cpp | ||
| output: | ||
| path: ./static/cpp-sdk-docs | ||
| lang: cpp | ||
|
|
||
| navigation: | ||
| - section: SDK References | ||
| contents: | ||
| - library: python-sdk | ||
| title: Python SDK | ||
| - library: cpp-sdk | ||
| title: C++ SDK | ||
| - api: API Reference | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[FernStyles.Current] Avoid time-relative terms like 'currently' that become outdated