Skip to content

Commit

Permalink
Merge pull request #1 from minaelee/add-initial-files
Browse files Browse the repository at this point in the history
Add initial files
  • Loading branch information
dannysheridan authored Mar 3, 2024
2 parents a5523b2 + 73bf2bc commit 60480ef
Show file tree
Hide file tree
Showing 18 changed files with 967 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: fern-check

on:
pull_request:
push:
branches:
- main

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Fern
run: npm install -g fern-api

- name: Check API is valid
run: fern check
22 changes: 22 additions & 0 deletions .github/workflows/generate-sdks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: generate-sdks

on:
push:
tags:
- "*"

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Fern
run: npm install -g fern-api

- name: Generate SDKs
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
fern generate --group publish --log-level debug --version ${{ github.ref_name }}
30 changes: 30 additions & 0 deletions .github/workflows/preview-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: preview-docs

on: pull_request

jobs:
run:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Fern
run: npm install -g fern-api

- name: Generate preview URL
id: generate-docs
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
OUTPUT=$(fern generate --docs --preview 2>&1) || true
echo "$OUTPUT"
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
echo "Preview URL: $URL"
echo "🌿 Preview your docs: $URL" > preview_url.txt
- name: Comment URL in PR
uses: thollander/actions-comment-pull-request@v2.4.3
with:
filePath: preview_url.txt
22 changes: 22 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: publish-docs

on:
push:
branches:
- main

jobs:
run:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/heads/main') && github.run_number > 1 }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Fern
run: npm install -g fern-api

- name: Publish Docs
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: fern generate --docs --log-level debug
163 changes: 161 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,161 @@
# docs-starter-fern-definition
Publish beautiful documentation in under 5 minutes using a Fern Definition.
<br/>
<div align="center">
<a href="https://www.buildwithfern.com/?utm_source=github&utm_medium=readme&utm_campaign=docs-starter-openapi&utm_content=logo">
<img src="/fern/docs/assets/fern.png" height="50" align="center" alt="header" />
</a>

<br/>

# Fern Docs Quickstart with Fern Definition

Create beautiful documentation in under 5 minutes, using the Fern Definition format to define your API.

</div>

Here's [an example.](https://docs.propexo.com/documentation)

> [!TIP]
> Prefer to use OpenAPI? We've got you covered: [Fern Docs Quickstart with OpenAPI Specification](https://github.com/fern-api/docs-starter-openapi).
## Requirements

- Node 18 or higher
- A [GitHub](https://github.com) account

---

## Instructions

### Step 1: Use this template

1. Click on the **Use this template** button. You must be logged into GitHub.
2. Choose the option to **create a new repository**. Name it `fern-docs`.

### Step 2: Clone and open the repository in your preferred code editor

Clone your newly created repository locally and open it in your favorite code editor, such as [Visual Studio Code](https://code.visualstudio.com/).

The `fern/` folder in your repository contains these files and folders:

```yml
├─ definition/
├─ api.yml
├─ pet.yml
├─ store.yml
└─ user.yml
├─ docs/
├─ assets/
├─ favicon.png
├─ logo_dark_mode.png
└─ logo_light_mode.png
└─ pages/
├─ sdks.mdx
└─ welcome.mdx
├─ docs.yml
├─ fern.config.json
└─ generators.yml
```

The `definition/` folder contains Fern Definition files for a sample API called Swagger Petstore. Fern uses these files to generate the API Reference section of your docs site.

The files inside the `pages/` folder are used to generate other documentation pages, such as a Welcome page. The `docs.yml` file sets up site navigation and custom styles.

### Step 3: Customize organization name and url

In the repository that you cloned locally, open the `fern.config.json` file, which looks like this:

```json
{
"organization": "Petstore",
"version": "0.x.x"
}
```

Replace `"Petstore"` with your own organization name within the quotes. Spaces are permitted. Leave the `version` number unchanged.

Open the `docs.yml` file and locate the `url`, which looks like this:

```yml
instances:
- url: petstore-ferndef.docs.buildwithfern.com
```
Replace `petstore-ferndef` with your own organization's name. Use only alphanumeric characters, hyphens, and underscores. Do not use spaces, and leave the rest of the URL (`.docs.buildwithfern.com`) unchanged.

### Step 4: Install the Fern CLI tool

Install the Fern CLI tool globally by running:

```shell
npm install -g fern-api
```

When prompted, log into and connect your GitHub account.

> [!NOTE]
> The above CLI command is a global command that you can run from any location. The `fern` commands in the following steps must be run from within your repository.

### Step 5: Generate your documentation

Run the following command:

```bash
fern generate --docs
```

Once the documentation is generated, Fern displays the URL where you can view the published documentation. For example:

```shell
┌─
│ ✓ petstore-ferndef.docs.buildwithfern.com
└─
```

Instead of `petstore-ferndef`, you should see the organization name that you added to `docs.yml` in Step 3.

### Step 6: Customize your documentation

You must run `fern generate --docs` after any modifications to re-generate and publish your documentation site.

To preview updates to your documentation before publishing changes, run `fern generate --docs --preview`.

To modify the API Reference:

- Update or replace the Fern Definition files in the `definition/` folder. See our documentation on [how to define your API with Fern Definition](https://buildwithfern.com/docs/define-your-api/ferndef/overview).

To modify the other docs pages or add new pages:

- Update the files located in the `docs/pages/` folder, such as `welcome.mdx`. See our documentation on [how to write content with Markdown and MDX](https://buildwithfern.com/docs/fern-docs/content/write-markdown).

To configure site navigation, styles, and see other configuration options:

- See [Fern Docs Configuration Overview](https://buildwithfern.com/docs/fern-docs/config/overview).

To learn about Fern's built-in component library you can use in Markdown:

- See the [Component Library](https://buildwithfern.com/docs/fern-docs/content/component-library/).

### Step 7: Set up a custom domain

If you wish to use a custom subdomain like `https://docs.YOUR_ORGANIZATION.com` or a subpath like `https://YOUR_ORGANIZATION.com/docs`, you can subscribe to the [Starter plan](https://buildwithfern.com/pricing). Once subscribed, update `docs.yml` with the custom domain configuration, replacing YOUR_ORGANIZATION with your own.

```yaml
- url: YOUR_ORGANIZATION.docs.buildwithfern.com
custom-domain: docs.YOUR_ORGANIZATION.com
```

Good luck creating beautiful and functional documentation! 🌿

---

## Support

Need help? Email us at (support@buildwithfern.com)[mailto:support@buildwithfern.com] or join our [Discord community](https://discord.com/invite/JkkXumPzcG).

## Customer showcase

Your docs can look this good:

- [Flatfile's API Reference](https://reference.flatfile.com/api-reference/events/create-an-event)
- [Sugeragent's Docs](https://docs.superagent.sh/)
- [Credal's Docs](https://docs.credal.ai/)
10 changes: 10 additions & 0 deletions fern/definition/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: petstore-ferndef-api
docs: |-
This API definition is written using the Fern Definition format. It's based on the Petstore 3.0 OpenAPI definition example provided by
Swagger [http://swagger.io](http://swagger.io).
error-discrimination:
strategy: status-code
auth: bearer
environments:
Sandbox: https://petstore3.swagger.io/api/v3
default-environment: Sandbox
Loading

0 comments on commit 60480ef

Please sign in to comment.