Skip to content

Issue #19800: Add Doc Comments Style Guide coverage infrastructure#19801

Merged
romani merged 1 commit into
checkstyle:masterfrom
gianmarcoschifone:config
May 16, 2026
Merged

Issue #19800: Add Doc Comments Style Guide coverage infrastructure#19801
romani merged 1 commit into
checkstyle:masterfrom
gianmarcoschifone:config

Conversation

@gianmarcoschifone

Copy link
Copy Markdown
Member

Issue #19800
This PR adds the infrastructure for tracking Checkstyle coverage of Documentation Comments Java Style Guidelines.
The checks (existing and new) will be added in follow-up PRs as rules are mapped.

@gianmarcoschifone

Copy link
Copy Markdown
Member Author

GitHub, generate website

@gianmarcoschifone gianmarcoschifone force-pushed the config branch 3 times, most recently from cee7225 to eaf23e6 Compare May 12, 2026 22:28
@gianmarcoschifone

Copy link
Copy Markdown
Member Author

GitHub, generate website

@Zopsss Zopsss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

items:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The doc-comments-style folder name should include either it's version or latest release date like google & openjdk style guide has.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was not able to find any reliable information about the latest version number or release date for this style guide. So for now, let's keep the doc-comments-style folder name as it is. In the future, if we find proper versioning or release information and need to support different versions, then we should update the naming accordingly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes exactly, I was looking for some info but didn't find any. I think this is from Sun from 2000, but I don't know if Oracle has modified it since then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove this file. All style guides have their own .js & .css files and they are copied from their official GitHub repo, these are used so we can re-create the cache page with exact UI of the original documentation.

I think you have copied this .js file from other style guides, am I right? Please correct me if I'm wrong.

If you have copied it from other style guides then we should remove it, and only keep the .html file.

@gianmarcoschifone gianmarcoschifone May 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

they are copied from their official GitHub repo

I think that openjdk's JS is copied from the google's one, the original openjdk web page doesn't have the link image we use. Also the two JS files look practically the same.

think you have copied this .js file from other style guides, am I right?

Yes exactly, I thought we did the same for openjdk.

If you have copied it from other style guides then we should remove it, and only keep the .html file.

Ok, I'll keep only the html file. The JS was only adding the link image in practice, not so useful

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes exactly, I thought we did the same for openjdk.

I didn't know about openjdk's files. Thanks for pointing this, I'll check that out too.

Ok, I'll keep only the html file. The JS was only adding the link image in practice, not so useful

Please remove that link image as well. For now, let's only keep the .html file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

styleguide.js is removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

from where did you find this html file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is the html of the oracle web page. I adjusted it because it had to be compatible with toc creation and it also had lot of js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I meant to ask that did you find it from a github repo or something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nope, I saved the web page of oracle and then modified it with some LLM's help, it took a while. Content is the same though. Does this have copyright issues?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure about copyright issues but if you would have copied it from a Github repo then we would be able to keep track of its release date/version number.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, no it's not from a github repo

final Node subSection = subSections.item(position);
final Node name = subSection.getAttributes().getNamedItem("name");

assertWithMessage("All sub-sections in '%s' must have a name", fileName)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please remove unrelated changes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

43 lines is the maximum allowed for the block, that's why I did that

hasDocComments = true;
expectedUrl = "https://github.com/search?q="
+ "path%3Asrc%2Fmain%2Fresources%20path%3A**%2Fdoc_comments_checks.xml+"
+ "repo%3Acheckstyle%2Fcheckstyle+"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%20path%3A**%2F${style guide name}repo%3Acheckstyle%2Fcheckstyle+ is common for all style guides, only the style guide name changes.

Please create a new method which accepts the style guide name and returns us the expectedUrl.

Example:

private static String getExpectedStyleGuideUrl(String styleGuideName) {
    return "https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%20path%3A**%2F"
        + styleGuideName
        + "repo%3Acheckstyle%2Fcheckstyle+";
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment on lines +2241 to +2270
.that(inputFolderUrl)
.startsWith("https://github.com/checkstyle/checkstyle/"
+ "tree/master/src/it/resources/com/" + styleName
+ "/checkstyle/test/");
.that(inputFolderUrl)
.startsWith("https://github.com/checkstyle/checkstyle/"
+ "tree/master/src/it/resources/com/" + stylePackageName
+ "/checkstyle/test/");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

revert unrelated changes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did that because that test is trying to get the package name from the style name (doc_comments_style -> doc_comments), but actually I named the package as doccomments without underscore, so they won't match.
I didn't see underscores in our package names so I thought it is not desirable to have them. Let me know what you think
https://github.com/checkstyle/checkstyle/pull/19801/changes/BASE..c8f2da4bc13aa293727dbdcdb710782dcd092520#diff-b63e6b6ebb32f3256c7aba537acd42c86cc467b7ef91aec2eda8be13759f21c4R20

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was pointing to the tab spaces you removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@gianmarcoschifone , Please keep indentation as it was

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry my bad

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Items

Comment thread config/jsoref-spellchecker/whitelist.words Outdated
@romani

romani commented May 14, 2026

Copy link
Copy Markdown
Member

GitHub, generate website

@romani

romani commented May 14, 2026

Copy link
Copy Markdown
Member

Please add links to sections like Use <code> style for keywords and names., and Automatic re-use of method comments and @author ,

I think almost all bold sentences should have anchors, to let us reference them more precisely. Each paragraph like this will be sliced and diced for requirements, so we need better granularity in reference. Highly likely each bold paragraph with be separate line in coverage table.

@gianmarcoschifone

gianmarcoschifone commented May 14, 2026

Copy link
Copy Markdown
Member Author

Please add links to sections like Use <code> style for keywords and names., and Automatic re-use of method comments and @author ,

I think almost all bold sentences should have anchors, to let us reference them more precisely. Each paragraph like this will be sliced and diced for requirements, so we need better granularity in reference. Highly likely each bold paragraph with be separate line in coverage table.

Yes I agree.
What about Format of a Doc Comment paragraph, where all the guidelines are in Notes?:

Chapter: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/5a9b174_20260514132556/styleguides/doc-comments-style/doc-comments-styleguide.html#format

Issue: #19808

@gianmarcoschifone gianmarcoschifone force-pushed the config branch 2 times, most recently from e464ac8 to b884677 Compare May 14, 2026 22:30
@gianmarcoschifone

Copy link
Copy Markdown
Member Author

GitHub, generate website

@romani

romani commented May 15, 2026

Copy link
Copy Markdown
Member

GitHub, generate website

@romani

romani commented May 15, 2026

Copy link
Copy Markdown
Member

@gianmarcoschifone , make "Notes" with anchor.
Again ... All bold text looks like titles for something, let's make them linkable

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Items

Comment thread src/site/resources/styleguides/doc-comments-style/doc-comments-styleguide.html Outdated
@gianmarcoschifone

Copy link
Copy Markdown
Member Author

@gianmarcoschifone , make "Notes" with anchor. Again ... All bold text looks like titles for something, let's make them linkable

Ok no problem. My concern is that there could be lot of -- or Requirement not possible to check, but I'll make all bold-text linkable as requested

@gianmarcoschifone

Copy link
Copy Markdown
Member Author

GitHub, generate website

@romani

romani commented May 15, 2026

Copy link
Copy Markdown
Member

Github, validate links

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good base version.

We will improve a lot later on.

@github-actions

Copy link
Copy Markdown
Contributor

@gianmarcoschifone

Copy link
Copy Markdown
Member Author

GitHub, generate website

@romani

romani commented May 16, 2026

Copy link
Copy Markdown
Member

Last #19801 (comment)

@romani

romani commented May 16, 2026

Copy link
Copy Markdown
Member

we lost all anchors in cached html.
We need such anchors.

@Zopsss , ^^^

@gianmarcoschifone

Copy link
Copy Markdown
Member Author

we lost all anchors in cached html. We need such anchors.

@Zopsss , ^^^

I'm sorry, what do you mean with anchors?

Should I put the JS file back?

@Zopsss

Zopsss commented May 16, 2026

Copy link
Copy Markdown
Member

we lost all anchors in cached html.
We need such anchors.

Yes, we lost it after removing .js file. @gianmarcoschifone please add it back.

@Zopsss

Zopsss commented May 16, 2026

Copy link
Copy Markdown
Member

what do you mean with anchors?

IMG_20260516_142111.jpg

These are the anchor links

Should I put the JS file back?

Yes.

@gianmarcoschifone

Copy link
Copy Markdown
Member Author

Not sure about the CI failure, I see it's happening here too #19820
@Zopsss

@romani

romani commented May 16, 2026

Copy link
Copy Markdown
Member

CI failure is merged, it will be full green on rebase, lets ignore such failure for now and let @Zopsss finalize review

@romani

romani commented May 16, 2026

Copy link
Copy Markdown
Member

GitHub, generate website

@romani

romani commented May 16, 2026

Copy link
Copy Markdown
Member

@gianmarcoschifone , in next PR please remove bigital numbers from chapter of Doc style table, there no number, in original doc and we should not use them, we just use wording of bold text as visual anchor for humans. that user can copy and search inpage to locate it, if they do not trust our link.

The Java Platform API Specification is defined by the documentation comments in the source code and any documents marked as specifications reachable from those comments.

can be shorted to The Java Platform API Specification is defined by the documentation comments in the source code ... or any other phrase that is distinct for search

@romani

romani commented May 16, 2026

Copy link
Copy Markdown
Member

Links works.
Good to merge

@romani romani merged commit b31976e into checkstyle:master May 16, 2026
125 of 126 checks passed
@gianmarcoschifone gianmarcoschifone deleted the config branch May 16, 2026 17:54
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.

3 participants