[doc] Fix \tparam names that do not match the declaration - #1486
Conversation
Every projection class in srs/projections/proj is `template <typename T, typename Parameters>`, but the Doxygen block above each one still documents `Geographic` and `Cartesian`, the parameters these classes took before ddce41f (Apr 2017) moved the internal representations. `T` has been undocumented since. All 152 blocks in 99 headers were byte-identical and every one is followed by `template <typename T, typename Parameters>`, so this is a straight replacement. The wording for `T` is taken from srs/projections/impl/base_dynamic.hpp, which already documents the same type as "calculation type". Comments only.
- clip_linestring.hpp: the Liang-Barsky strategy documents \tparam B and \tparam P, the template takes Box and Point. - simplify.hpp: douglas_peucker_point writes '\tparam the enclosed point type', so Doxygen reads 'the' as the parameter name. It is Point. - azimuth.hpp: default_strategy documents CalculationType, the template has only CSTag. - transform.hpp: the four lines read '\tparam CoordinateSystemTag 1,2 coordinate system tags', meaning both at once, so Doxygen sees a name that does not exist. Split into the eight real parameters. Source and target follow from transform(Geometry1 const&, Geometry2&), where the second one is the mutable output. Comments only.
|
Thanks! I think this include the other PR #1485 |
|
Yes, this one includes 1485 -- I diffed them, all 251 added lines of 1485 are in here, plus 11 more Closing 1485 now, so this is the only one to review |
There was a problem hiding this comment.
Thanks for the PR! Your commit message mentions tool use, could you disclose the tools used here for reproducibility?
Since this is a lot to review manually, I think tooling-based validation is helpful here. The clang-doc tool in LLVM can parse both template declarations and doxygen and generates yaml-output documenting both the tparam-lines and the actual template parameters in a strucured format. This yaml-output can then be queried for discrepancies using https://github.com/mikefarah/yq .
git checkout doc/tparam-names-match-declaration
git log --name-only --pretty="" develop..HEAD | sort | uniq | sed 's/include\//#include </g' | sed 's/$/>/g' > headers.cpp && echo "int main() {}" >> headers.cpp
clang-doc --format=yaml --output=clang-doc-geometry --doxygen --extra-arg=-I$HOME/dev/boost headers.cpp
git checkout develop
clang-doc --format=yaml --output=clang-doc-geometry-develop --doxygen --extra-arg=-I$HOME/dev/boost headers.cpp
for file in clang-doc-geometry/*.yaml; do sh match.sh $file ; done > discrepancies.txt
for file in clang-doc-geometry-develop/*.yaml; do sh match.sh $file ; done > discrepancies-develop.txt
diff discrepancies-develop.txt discrepancies.txt | grep '^>'Output (see comment):
> /Users/tinko/dev/boost/boost/geometry/srs/projections/proj/ob_tran.hpp:581: boost::geometry::projections::ob_tran_static: template [StaticParameters, T, Parameters], doxygen \tparam [T, Parameters]
The above grep expression is meant to only match lines where the PR changes tparam comments and it still does not match the C++ declaration.
I think, besides the two commented comments, this PR is correct and can be merged after addressing.
LLM disclosure: I used Codex with model GPT 5.6 Sol to harden the query expression in the match.sh script after an initial draft against the full list of yaml files generated by clang-doc.
Match script used:
match.sh
@barendgehrels The above verification workflow runs reasonably fast (generates roughly 14,000 yaml files, though), clang-doc and yq are both open source tools. Running it on the broader library reveals more mismatches (for template parameters only: 30 where tparam comments exist but do not exactly match the template parameters, 97 where template parameters exist but no tparam comments). Do you think, we want a CI-action for this to catch future implementation/documentation drift? It probably extends straightforwardly to function arguments and other things with structured doxygen documentation too. I could create a PR next week which tolerates existing mismatches but fails on new ones.
…t order The \tparam list for ob_tran_static named T and Parameters but not StaticParameters, which the declaration takes first. Added it in declaration order. In tmerc.hpp the doxygen block for tmerc_ellipsoid was separated from the declaration by a commented-out copy of the approximate implementation, so doxygen bound the comment to nothing. Moved the commented-out copy below the real declaration. Nothing else changed: the file is the same 715 lines reordered, plus one blank separator. This is the only place in srs/projections/proj where a doxygen block is detached this way. Two other candidates in isea.hpp turned out to be plain /* */ comments in the detail namespace, not doxygen.
|
First off, thank you 🙏🏼 You read my PR and built a checker to validate the whole diff against develop, and then took it further and asked whether the project wants this permanently. Seeing it turn into a CI proposal is the best outcome I could have hoped for Tools, since you asked. The finder is driftkit, a small thing I wrote and keep as a repo, Python and stdlib only. I built it with Claude Opus 5 . The tool gives me a list of candidates, and I read each one against the declaration before it becomes a diff, which is why the not included section of this PR exists at all Your And it lines up with your own numbers - the 30 mismatched ones are what driftkit was pointed at from the start, the 97 missing ones it has not been looking for Both review points are in:
I checked the rest of On the CI action, yes, and "tolerate existing, fail on new" is the right shape. And a hard gate on 127 findings never gets switched on so clang-doc reading the real declarations is a much better base than regular expressions over headers, especially for the missing half, where you need the full template parameter list rather than the names that happen to be in the comment. Happy to feed you anything useful from my end 🙌🏼 |
|
👍 👍 👍 |
tinko92
left a comment
There was a problem hiding this comment.
The check outlined in the previous comment completes successfully with the third commit.
|
Squashed and merged due to having two approvals and passing CI. |
Four Doxygen blocks name a template parameter the declaration below them does not have.
algorithms/detail/overlay/clip_linestring.hpp:43B,PBox,Pointalgorithms/simplify.hpp:82thePointstrategies/azimuth.hpp:27CalculationTypeCSTagexistsstrategies/transform.hpp:41CoordinateSystemTag,CoordinateSystem,D,PointTwo of these are interesting beyond a rename.
simplify.hppreads\tparam the enclosed point type, with the name left out, so Doxygen takestheas the parameter name and the description becomes "enclosed point type" attached to a parameter that does not exist.transform.hppdocuments pairs in one line each:The intent is clear to a human and invisible to Doxygen, which reads four names none of which exist, and leaves all eight real parameters undocumented. Split into eight lines.
Which one is source and which is target is not a guess:
transform(Geometry1 const& geometry1, Geometry2& geometry2)takes the first by const reference and the second mutable, andselect_strategypassesGeometry1's traits into the odd positions.azimuth.hppsimply lists one parameter too many, so that line is gone.Not included
The same sweep flags twelve more, and they are a different kind: the block documents parameters that belong to a member function rather than to the class, e.g.
detail/not.hppdocumentsGeometry1/Geometry2fromapplyon a class templated only onPolicy, and the pythagoras distance strategies do the same withPoint1/Point2. Fixing those means deciding where the documentation should live, which is yours to make rather than mine. Point at any of them and I will send a follow-up.Checks
Comments only, no declaration touched. The check reported 24 before and 16 after, and the sixteen left are exactly the group described above.
Found with a small tool that pulls every
\paramand\tparamname out of a Doxygen block and compares it against the declaration that follows, then re-run afterwards to confirm the count moved by exactly the number of edits.