Documentation Coverage
(require doc-coverage) | package: doc-coverage |
This library provides functions for inspecting the number of bindings a module exports with and without corresponding Scribble documentation, as well as Rackunit tests based on this information. This allows a module author to enforce in a test suite that their modules provide no undocumented bindings.
source code: https://github.com/jackfirth/doc-coverage
1 Basic Module Documentation Reflection
These primitives for examining module documentation information allow the construction of tests and reflection tools. They are implemented with Racket’s native module reflection functions combined with Scribble’s xref? tables.
procedure
(module->all-exported-names mod) → (list/c symbol?)
mod : symbol?
> (module->all-exported-names 'racket/match)
'(legacy-match-expander?
match-...-nesting
match-expander?
prop:legacy-match-expander
prop:match-expander
syntax-local-match-introduce
exn:misc:match?
match-equality-test
==
define-match-expander
define/match
failure-cont
match
match*
match*/derived
match-define
match-define-values
match-lambda
match-lambda*
match-lambda**
match-let
match-let*
match-let*-values
match-let-values
match-letrec
match-letrec-values
match/derived
match/values
struct*)
procedure
(module->documented-exported-names mod) → (list/c symbol?)
mod : symbol?
> (module->documented-exported-names 'racket/match)
'(legacy-match-expander?
match-expander?
prop:legacy-match-expander
prop:match-expander
syntax-local-match-introduce
exn:misc:match?
match-equality-test
==
define-match-expander
define/match
failure-cont
match
match*
match*/derived
match-define
match-define-values
match-lambda
match-lambda*
match-lambda**
match-let
match-let*
match-let*-values
match-let-values
match-letrec
match-letrec-values
match/derived
match/values
struct*)
procedure
(module->undocumented-exported-names mod) → (list/c symbol?)
mod : symbol?
> (module->undocumented-exported-names 'racket/match) '(match-...-nesting)
2 Module Documentation Statistics
These procedures are simple numeric tools built on the core module documentation reflection functions.
procedure
mod : symbol?
> (module-num-exports 'racket/match) 29
> (module-num-exports 'racket/list) 57
procedure
→ exact-nonnegative-integer? mod : symbol?
> (module-num-documented-exports 'racket/match) 28
procedure
→ exact-nonnegative-integer? mod : symbol?
> (module-num-undocumented-exports 'racket/match) 1
procedure
(module-documentation-ratio mod) → exact-nonnegative-number?
mod : symbol?
> (module-documentation-ratio 'racket/match) 28/29
3 Testing Module Documentation
These Rackunit checks allow flexible specification of requirements of a modules documentation, including require all exports be documented, only specific exports, or that a module overall document a minimum percentage of its exports.
procedure
(check-all-documented mod) → void?
mod : symbol?
> (check-all-documented 'racket/base)
--------------------
FAILURE
name: check-all-documented
location: (eval 12 0 12 1)
expression: (check-all-documented (quote racket/base))
params: (racket/base)
Module racket/base has 3 undocumented bindings:
expand-for-clause
for-clause-syntax-protect
syntax-pattern-variable?
--------------------
procedure
(check-documented mod binding) → void?
mod : symbol? binding : symbol?
> (check-documented 'racket/list 'second)
> (check-documented 'racket/match 'match-...-nesting)
--------------------
FAILURE
name: check-documented
location: (eval 14 0 14 1)
expression: (check-documented (quote racket/match) (quote match-...-nesting))
params: (racket/match match-...-nesting)
Module racket/match does not document binding match-...-nesting
--------------------
procedure
(check-documentation-ratio mod ratio) → void?
mod : symbol? ratio : (and/c number? positive-real?)
> (check-documentation-ratio 'racket/match 0.99)
--------------------
FAILURE
name: check-documentation-ratio
location: (eval 15 0 15 1)
expression: (check-documentation-ratio (quote racket/match) 0.99)
params: (racket/match 0.99)
Module racket/match does not document at least 99.0% of its bindings, only documents 96.55172413793103%
--------------------
4 raco doc-coverage: Documentation Coverage
The raco doc-coverage command checks the documentation coverage in specific modules.
-h or --help —
show help information for this command -- —
do not treat any remaining arguments as switches