Statically define convenience fns so clj-kondo/cljdoc can see them#15
Open
jsavyasachi wants to merge 2 commits into
Open
Statically define convenience fns so clj-kondo/cljdoc can see them#15jsavyasachi wants to merge 2 commits into
jsavyasachi wants to merge 2 commits into
Conversation
The md5/sha-* convenience fns were interned at load time, so clj-kondo and cljdoc could not see them (the cljdoc API page was empty and the single-segment digest ns produced unresolved-symbol errors). The (comment (declare ...)) workaround only helped clj-kondo, not cljdoc, and not the legacy namespace. Generate the fns for the standard JCA algorithm set as real defns (with docstrings and arglists) via dev/gen.clj, committed into both source namespaces. A create-missing-fns! fallback still interns vars for any additional algorithms a JVM exposes at runtime, so every algorithm in (algorithms) keeps a matching var. Closes clj-commons#14.
It used a lazy for, so the ns-resolve assertions were never realized. Switch to doseq and resolve in the source namespace, turning it into a real check that every algorithm has a convenience fn.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14.
Problem
The
md5/sha-*convenience fns are interned at load time, so they don't exist statically: cljdoc's API page is empty, and the single-segmentdigestnamespace gives consumers "unresolved symbol" errors. The(comment (declare ...))hint helped clj-kondo forclj-commons.digestonly - not cljdoc (which skipscommentforms), and not the legacy namespace.Change
md2,md5,sha,sha1,sha-1,sha-224/256/384/512,sha3-224/256/384/512) as realdefns with docstrings + arglists, viadev/gen.clj, committed into both namespaces between markers. Drop thecomment/declarehack.create-missing-fns!fallback that interns vars for any extra algorithms a JVM exposes at runtime, so(algorithms)coverage is unchanged.utils-test: it used a lazyfor, so itsns-resolveassertions never ran; now it actually checks every algorithm has a convenience fn.Effect
clj-kondo --lint src testreports 6 unresolved-symbol errors for the convenience fns; cljdoc shows none of them.md5/sha-256/… in both namespaces with real docstrings, no comment hack.lein testgreen (52 assertions, up from 18 once the no-op test actually runs).Two unrelated, pre-existing clj-kondo findings remain (the byte-array
extend-protocolform and thenilimpl's unused bindings) - out of scope here.The generated region is reproducible:
bb dev/gen.cljis idempotent.