Skip to content

Automerge-C API Docs #5

@ivanreese

Description

@ivanreese

I was talking to @jkankiewicz about getting the generated Automerge-C docs hosted and linked from the site.

To build the docs:

cmake -E make_directory automerge-c/build
cmake -S automerge-c -B automerge-c/build
cmake --build automerge-c/build --target automerge_docs
cmake -E copy_directory automerge-c/build/docs/html <website-documentation-directory>/automerge-c

The docs end up at <website-documentation-directory>/automerge-c/index.html

They're versioned along with the rest of the repo, so adding a step to generate and upload (to gh-pages) these docs as part of the JS or rust release workflow perhaps makes sense. (Will need to talk to @alexjg about this.) Worth noting — the JS docs are hosted on GH Pages, but I think the rust docs are hosted elsewhere, so we might need to build them as part of the JS release process (because all GH Pages stuff seemingly needs to be uploaded together).

Here's a sketch GPT generated:

publish-js-docs:
    runs-on: ubuntu-latest
    if: "!github.event.release.prerelease"
    defaults:
      run:
        working-directory: ./javascript
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v5
        with:
          node-version: "20.x"
          registry-url: "https://registry.npmjs.org"
      - name: Install wasm-bindgen-cli
        run: cargo install wasm-bindgen-cli wasm-opt
      - name: Install wasm32 target
        working-directory: rust
        run: rustup target add wasm32-unknown-unknown
      - name: yarn install
        run: yarn install
      - name: build js
        run: node ./scripts/build.mjs
      - name: build js docs
        run: npx typedoc --out api-docs/js

      # 👇 Added C docs build
      - name: Set up CMake
        uses: jwlawson/actions-setup-cmake@v2

      - name: Build C docs
        run: |
          cmake -E make_directory automerge-c/build
          cmake -S automerge-c -B automerge-c/build
          cmake --build automerge-c/build --target automerge_docs
          mkdir -p api-docs/c
          cp -r automerge-c/build/docs/* api-docs/c || true

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          branch: gh-pages
          folder: ./javascript/api-docs
          target-folder: api-docs

Which should put the docs here:

  • /api-docs/js/ → JS docs
  • /api-docs/c/ → C docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions