tecosaur / CheckDoc.jl

Documentation linting
MIT License
6 stars 1 forks source link

Consider a struct-based approach #5

Open asinghvi17 opened 3 months ago

asinghvi17 commented 3 months ago

This package looks really cool! I was looking at it and thought that for Makie.jl use and others it may need user extensibility. Have you considered a struct-based approach, where each check is a type, and some common API method is defined for that type?

Something like this:

abstract type AbstractDocstringCheck end

struct CheckNonEmpty <: AbstractDocstringCheck end

function check(::CheckNonEmpty, ::Symbol, ::Dict, raw::String, ::Any)::Union{ShortIssue, Vector{ShortIssue}}
    if all(isspace, raw)
        ShortIssue(:error, "The documentation string should not be empty"), true
    end
end

or something like this. Then users can call check(module; checks = AbstractDocstringCheck[...]) and define their own checks elsewhere!

asinghvi17 commented 3 months ago

This kind of already exists since you can push! to the const array defined in the main file, I thought formalizing the interface might be nice though.