Skip to content

Instantly share code, notes, and snippets.

@RaphaelS1
Last active September 19, 2022 05:35
Show Gist options
  • Save RaphaelS1/1e1de87218eb8d58b0c2907e4a947fd5 to your computer and use it in GitHub Desktop.
Save RaphaelS1/1e1de87218eb8d58b0c2907e4a947fd5 to your computer and use it in GitHub Desktop.
Workflow to check if all objects in Julia package documented as expected.
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
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
module MyPackage
export FunctionA, FunctionB, FunctionC
end
@RaphaelS1
Copy link
Author

UPDATE: Massively simplified the above to require no extra dependencies or syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment