Skip to content

Commit

Permalink
[PoC] Documentation generation (#275)
Browse files Browse the repository at this point in the history
* Add doxyfile

* Configure doxygen

* Add workflow

* Fix workflow

* Improve enums and functions

* Remove test docstrings

* Sync webgpu.h

* Remove TODOs from enum docstrings

* Fix doc generation workflow and clean up Doxyfile

* Add doc theme license

* Make doc target phony

* Remove theme, use built-in sidebar-style theme

We'll potentially look into theming (or using another doxygen-compatible
documentation generator) later on.

Also moves the gitignore line to doc/ so that Doxygen has a directory to
generate into.

* nits: Remove version, tweak WIP notice

---------

Co-authored-by: Kai Ninomiya <[email protected]>
  • Loading branch information
eliemichel and kainino0x authored Jun 10, 2024
1 parent f686ddf commit 0dc92bd
Show file tree
Hide file tree
Showing 7 changed files with 635 additions and 29 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/gen-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: gen-docs

on:
push:
branches: ["main"]
workflow_dispatch:
pull_request:

# Allow only one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Generate and build docs
gen-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '>=1.21.0'
- uses: ssciwr/doxygen-install@v1
with:
version: '1.10.0'
- run: make doc
- uses: actions/upload-pages-artifact@v3
with:
path: doc/generated/html

# Deployment job
deploy:
if: ${{ success() && github.ref == 'refs/heads/main' }}
needs: gen-docs

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
138 changes: 138 additions & 0 deletions Doxyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# This file was initially generated by Doxyfile 1.10.0 and all entries left
# to their default value have been removed for the sake of clarity.

#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------

PROJECT_NAME = "WebGPU Headers"

# This is the version of webgpu.h. Currently we don't have release versions.

PROJECT_NUMBER =

# This appears at the top of each page and should give viewer a quick idea
# about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "The WebGPU C API"

# The Doxygen-generated documentation is written in doc/generated. Make sure
# to keep this in sync with the deployment workflow file
# (.github/workflows/gen-docs.yml).

OUTPUT_DIRECTORY = doc/generated

# Since webgpu.h is a C API, we set the OPTIMIZE_OUTPUT_FOR_C tag to YES so
# that Doxygen generates an output that is more tailored for C.

OPTIMIZE_OUTPUT_FOR_C = YES

#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------

# The WebGPU C API does not have cases of symbols only differing by case, so
# we can afford to turn this to YES even on non-case sensitive file systems.
# This options helps getting slightly better path names, although it is still
# overall not satisfying so as soon as we have a proper way to generate good
# human-memorable URLs we could turn this back to NO or SYSTEM.

CASE_SENSE_NAMES = YES

# No need to show header file, since there is only webgpu.h. When using this
# Doxyfile with implementation-specific extensions (e.g., wgpu.h), it could
# be useful to turn this back to YES.

SHOW_HEADERFILE = NO

# Instead of letting Doxygen sort definition alphabetically, we have it rely
# on the order from webgpu.h. Since the latter is auto-generated, we can
# expect the order there to be sound and consistent.

SORT_MEMBER_DOCS = NO

# No need to show used files as there is only webgpu.h

SHOW_USED_FILES = NO

# And no need for the Files page neither.

SHOW_FILES = NO

# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
# by doxygen. The layout file controls the global structure of the generated
# output files in an output format independent way. To create the layout file
# that represents doxygen's defaults, run doxygen with the -l option. You can
# optionally specify a file name after the option, if omitted DoxygenLayout.xml
# will be used as the name of the layout file. See also section "Changing the
# layout of pages" for information.
#
# Note that if you run doxygen from a directory containing a file called
# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
# tag is left empty.

LAYOUT_FILE =

#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------

# When adding extra files, separate them with spaces.

INPUT = webgpu.h

#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------

# The header file itself is often a good source of information, so we have
# documented entries be cross-referenced with their source.

SOURCE_BROWSER = YES

#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------

# Make sure the WGPU/wgpu prefix of type/function names are ignored while
# sorting member names in the alphabetical index.

IGNORE_PREFIX = WGPU,wgpu

#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------

# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
# The default value is: YES.

GENERATE_HTML = YES

# Sidebar-based page layout (https://www.doxygen.nl/manual/customize.html)

DISABLE_INDEX = YES
GENERATE_TREEVIEW = YES
FULL_SIDEBAR = YES

# Enum values look weird in Doxygen output in general, but a bit less weird
# when only allowing 1 value per line.

ENUM_VALUES_PER_LINE = 1

#---------------------------------------------------------------------------
# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------

# We do not need a LaTeX documentation

GENERATE_LATEX = NO

#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------

# We need to expand macros to prevent the empty defines used as tags like
# WGPU_ENUM_ATTRIBUTE to be treated by Doxygen and mess up with the whole
# documentation.

MACRO_EXPANSION = YES
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: gen
.PHONY: gen gen-check doc

gen: schema.json webgpu.yml
go run ./gen -schema schema.json -yaml webgpu.yml -header webgpu.h
Expand All @@ -9,3 +9,6 @@ gen-check: gen
git diff -- webgpu.h; \
exit 1; \
}

doc: webgpu.h Doxyfile
doxygen Doxyfile
1 change: 1 addition & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/generated/
Loading

0 comments on commit 0dc92bd

Please sign in to comment.