-
Notifications
You must be signed in to change notification settings - Fork 33
feat(docs): publish YARD API docs + llms.txt to GitHub Pages #480
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
Changes from all commits
4bddd4f
edfee5b
6b06c74
f85754a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||||||||||||||||||||||||||
| name: Publish API Docs | ||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||
| tags: ['v*'] | ||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||||||||||||
| group: pages | ||||||||||||||||||||||||||||||||||||
| cancel-in-progress: false | ||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||||||||||||||||||||||||||||||||
| - uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 | ||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||
| bundler-cache: true | ||||||||||||||||||||||||||||||||||||
| - run: ./script/docs | ||||||||||||||||||||||||||||||||||||
|
greptile-apps[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||
| - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 | ||||||||||||||||||||||||||||||||||||
| - name: Archive site | ||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||
| tar \ | ||||||||||||||||||||||||||||||||||||
| --dereference --hard-dereference \ | ||||||||||||||||||||||||||||||||||||
| --directory docs/_site \ | ||||||||||||||||||||||||||||||||||||
| -cvf "$RUNNER_TEMP/artifact.tar" \ | ||||||||||||||||||||||||||||||||||||
| --exclude=.git \ | ||||||||||||||||||||||||||||||||||||
| --exclude=.github \ | ||||||||||||||||||||||||||||||||||||
| . | ||||||||||||||||||||||||||||||||||||
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||
| name: github-pages | ||||||||||||||||||||||||||||||||||||
| path: ${{ runner.temp }}/artifact.tar | ||||||||||||||||||||||||||||||||||||
| retention-days: 1 | ||||||||||||||||||||||||||||||||||||
| if-no-files-found: error | ||||||||||||||||||||||||||||||||||||
| deploy: | ||||||||||||||||||||||||||||||||||||
| needs: build | ||||||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||||||
| name: github-pages | ||||||||||||||||||||||||||||||||||||
| url: ${{ steps.deployment.outputs.page_url }} | ||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+44
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||
| - uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 | ||||||||||||||||||||||||||||||||||||
| id: deployment | ||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,3 +50,5 @@ | |
|
|
||
| .vscode | ||
| .idea/ | ||
| docs/_site/ | ||
| .yardoc/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --output-dir docs/_site | ||
| --markup markdown | ||
| lib/**/*.rb | ||
| - | ||
| README.md | ||
| CHANGELOG.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,9 @@ | |
| source "https://rubygems.org" | ||
|
|
||
| gemspec | ||
|
|
||
| group :docs do | ||
| gem "yard" | ||
| gem "yard-markdown" | ||
| gem "webrick" | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/sh | ||
| set -eu | ||
| cd "$(dirname "$0")/.." | ||
| bundle config set --local with 'docs' | ||
| bundle install | ||
| rm -rf docs/_site | ||
| # 1. Generate HTML docs (default YARD format). | ||
| bundle exec yard doc | ||
| # 2. Generate Markdown docs alongside the HTML, using the yard-markdown plugin. | ||
| # We point output at the same docs/_site directory so .md files land next to .html. | ||
| # --no-cache forces a re-parse so the markdown formatter sees fresh registry data. | ||
| # --plugin yard-markdown ensures the plugin is loaded without relying on ~/.yard/config. | ||
| bundle exec yard doc --plugin yard-markdown --format markdown --no-cache --output-dir docs/_site | ||
| # 3. Generate llms.txt (index) from the markdown output, so the published site | ||
| # is consumable by LLM tooling. | ||
| bundle exec ./script/llms-txt |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/sh | ||
| set -eu | ||
| cd "$(dirname "$0")/.." | ||
| bundle config set --local with 'docs' | ||
| bundle install --quiet | ||
| if [ "${1:-}" = "--static" ]; then | ||
| if [ ! -d docs/_site ]; then | ||
| ./script/docs | ||
| fi | ||
| exec bundle exec ruby -run -e httpd -- docs/_site -p 4000 | ||
| fi | ||
| exec bundle exec yard server --reload --port 4000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env ruby | ||
| # frozen_string_literal: true | ||
|
|
||
| # Generates llms.txt (curated index) from the Markdown docs produced by | ||
| # `yard --format markdown` in docs/_site. See https://llmstxt.org for the format. | ||
|
|
||
| require "pathname" | ||
|
|
||
| ROOT = Pathname.new(__dir__).join("..").expand_path | ||
| SITE = ROOT.join("docs/_site") | ||
| require ROOT.join("lib/workos/version").to_s | ||
|
|
||
| abort "docs/_site is missing — run script/docs first" unless SITE.directory? | ||
|
|
||
| md_files = Pathname.glob(SITE.join("**/*.md")).sort_by { |p| p.relative_path_from(SITE).to_s } | ||
|
|
||
| title_for = lambda do |path| | ||
| first_heading = path.each_line.lazy.map(&:strip).find { |l| l.start_with?("# ") } | ||
| first_heading ? first_heading.sub(/^#\s+/, "").sub(/\s*<a id=.*?<\/a>\s*$/, "").strip : path.basename(".md").to_s | ||
| end | ||
|
|
||
| index_lines = [] | ||
| index_lines << "# WorkOS Ruby SDK v#{WorkOS::VERSION}" | ||
| index_lines << "" | ||
| index_lines << "> API client for WorkOS. This file indexes the auto-generated YARD documentation for the `workos` gem so language models can locate per-class references." | ||
| index_lines << "" | ||
| index_lines << "## API Reference" | ||
| index_lines << "" | ||
| md_files.each do |path| | ||
| rel = path.relative_path_from(SITE).to_s | ||
| index_lines << "- [#{title_for.call(path)}](#{rel})" | ||
| end | ||
| index_lines << "" | ||
|
|
||
| SITE.join("llms.txt").write(index_lines.join("\n")) | ||
|
|
||
| puts "Wrote #{SITE.join("llms.txt")} (#{md_files.size} entries)" |
Uh oh!
There was an error while loading. Please reload this page.