Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add test to detect public names without a docstring #313

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

gdalle
Copy link
Contributor

@gdalle gdalle commented Nov 24, 2024

Fixes #90

Source:

  • Add a function test_undocumented_names which checks whether public names are documented or not (only on Julia 1.11 and later). It does so by verifying that Docs.undocumented_names(module) is either empty or contains only the module name itself.

Tests:

  • Add a kwarg test_undocumented_names to test_all
  • Add tests with one fully documented module and one partially documented module.

Docs:

  • Add docs page about test_undocumented_names

Chores:

  • Bump version to v0.9.0 (BREAKING CHANGE)
  • Update CHANGELOG.

Copy link

codecov bot commented Nov 24, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.93%. Comparing base (1fca5d9) to head (83150f4).

Files with missing lines Patch % Lines
src/Aqua.jl 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #313      +/-   ##
==========================================
+ Coverage   74.90%   74.93%   +0.03%     
==========================================
  Files          11       12       +1     
  Lines         761      774      +13     
==========================================
+ Hits          570      580      +10     
- Misses        191      194       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gdalle gdalle changed the title feat: add test for undocumented public names feat: add test to detect public names without a docstring Nov 24, 2024
src/Aqua.jl Outdated Show resolved Hide resolved
Copy link

@KeithWM KeithWM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comments. I am not an experienced enough Julia developer to be entirely confident that everything I say is correct, but I hope you value the suggestions/questions.

docs/src/index.md Outdated Show resolved Hide resolved
src/Aqua.jl Show resolved Hide resolved

!!! warning
For Julia versions before 1.11, this does not test anything.
"""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer seeing this warning in code with an @warn rather than a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means adding a warning for every test below Julia 1.11, not sure people will like that. The fact that it does nothing on 1.10 can already be seen from the fact that the relevant @testset is empty

Copy link

@KeithWM KeithWM Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize now that this implementation relies heavily on the "new" public keyword, which was not actually in the original issue (as it predated the keyword). Given that a main reason for introducing the public keyword was that previously something being documented was used to show it was part of the API, I think the proposed implementation is a good idea. But I'm not quite sure how to deal with the expectations towards <1.11 users. It could help to change the name of the check to something like test_undocumented_api, test_undocumented_public or something else that include the word "public" without being as verbose as test_undocumented_public_names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that Docs.undocumented_names is not defined on 1.10, I'm not sure we can do anything meaningful before 1.11 (unless that function is added to Compat.jl)

test/test_undocumented_names.jl Show resolved Hide resolved
src/Aqua.jl Show resolved Hide resolved
Copy link

@ericphanson ericphanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the feature and implementation look good to me, but I think it is breaking to add a new default-on check (both on the principle that it would be very annoying to start failing CI "out of nowhere" and precedent, e.g. #174).

I think this could start off-by-default or just be v0.9.0.

"""
function test_undocumented_names(m::Module)
@static if VERSION >= v"1.11"
undocumented_names = filter(n -> n != nameof(m), Docs.undocumented_names(m))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
undocumented_names = filter(n -> n != nameof(m), Docs.undocumented_names(m))
undocumented_names = filter(n -> n != nameof(m), Docs.undocumented_names(m))

Why the filter? It's good practice for a module to have a docstring.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context: #313 (comment)

@gdalle
Copy link
Contributor Author

gdalle commented Nov 24, 2024

I think this could start off-by-default or just be v0.9.0.

Either is fine by me. I guess it depends whether there are other pending breaking changes which might benefit from tagging v0.9.0 for this one.

Also I'm worried that if we leave this test off at first we'll never remember to turn it on at the next breaking release.

@ericphanson
Copy link

Personally I think doing a breaking release whenever there's a new check is alright, and just have all checks opt-out by default. I'm not an Aqua maintainer, but I've used aqua in a lot of repos with varying levels of activity, and I haven't found breaking releases of Aqua particularly annoying. No other packages (should) depend on Aqua so being on an old release doesn't hold back other packages, and it's fine to just stay on an older release until the next maintenance pass. I think mixing opt-in and opt-out is a bit more confusing and requires more attention for users.

@gdalle
Copy link
Contributor Author

gdalle commented Nov 24, 2024

Tentatively bumping the version to v0.9.0, we'll see what the maintainers think

@KeithWM
Copy link

KeithWM commented Nov 24, 2024

Tentatively bumping the version to v0.9.0, we'll see what the maintainers think

I think the whole point of semver falls to bits if packages start cutting corners on what is and what is not breaking. I'm not sure what I usually see happening in practice, what kind of compat (caret, fixed, free) package developers have with their Aqua (test) dependency. A suggestion might be that Aqua warns users of newer versions, without actually breaking anything. Or that the documentation recommends dependents do not use a compat for Aqua, to avoid Aqua-clearance giving a false sense of security that all is well.

Copy link

@KeithWM KeithWM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this, but I wouldn't take my approval as a sufficient proof that the PR is good.


!!! warning
For Julia versions before 1.11, this does not test anything.
"""
Copy link

@KeithWM KeithWM Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize now that this implementation relies heavily on the "new" public keyword, which was not actually in the original issue (as it predated the keyword). Given that a main reason for introducing the public keyword was that previously something being documented was used to show it was part of the API, I think the proposed implementation is a good idea. But I'm not quite sure how to deal with the expectations towards <1.11 users. It could help to change the name of the check to something like test_undocumented_api, test_undocumented_public or something else that include the word "public" without being as verbose as test_undocumented_public_names.

@j-fu
Copy link

j-fu commented Nov 25, 2024

LGTM

@j-fu j-fu mentioned this pull request Nov 25, 2024
28 tasks
@gdalle
Copy link
Contributor Author

gdalle commented Nov 28, 2024

@lgoettgens would you mind taking a look? I got several reviews but none of them from maintainers I think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test if all exported names has a docstring
5 participants