Last active
September 19, 2022 05:35
-
-
Save RaphaelS1/1e1de87218eb8d58b0c2907e4a947fd5 to your computer and use it in GitHub Desktop.
Workflow to check if all objects in Julia package documented as expected.
This file contains 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
using MyPackage | |
documented = map(x -> replace(string(x), "MyPackage." => ""), | |
collect(keys(Docs.meta(MyPackage)))); | |
expected = []; | |
map(x -> | |
x != :MyPackage && ## remove package name | |
Symbol(eval(x)) == x && # remove aliases | |
parentmodule(eval(x)) == MyPackage && ## check if this package is parent module | |
push!(expected, strip(String(x))), names(MyPackage)); ## push if all true | |
missings = setdiff(expected, documented); ## under-documented, critical error | |
extras = setdiff(documented, expected); ## over-documented, warning | |
if length(missings) > 0 | |
error("Forgot to document: ", missings) | |
elseif length(extras) > 0 | |
@warn "Extra objects documented:" extras | |
else | |
@info "All objects documented as expected:" expected | |
end |
This file contains 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
name: Documentation | |
on: | |
push: | |
branches: | |
- main | |
- master | |
tags: '*' | |
pull_request: | |
jobs: | |
build: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: julia-actions/setup-julia@v1 | |
with: | |
version: '1.6' | |
- name: Install dependencies | |
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' | |
- name: Build and deploy | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token | |
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key | |
run: julia --project=docs/ docs/make.jl | |
- name: Check expected and documented objects | |
if: github.event_name == 'pull_request' | |
run: julia --project=docs/ check_doc_coverage.jl |
This file contains 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
module MyPackage | |
export FunctionA, FunctionB, FunctionC | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UPDATE: Massively simplified the above to require no extra dependencies or syntax.