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

stylecheck: flag doc references to nonexisting objects #1182

Open
dominikh opened this issue Feb 8, 2022 · 4 comments
Open

stylecheck: flag doc references to nonexisting objects #1182

dominikh opened this issue Feb 8, 2022 · 4 comments
Labels
needs-decision We have to decide if this check is feasible and desirable new-check

Comments

@dominikh
Copy link
Owner

dominikh commented Feb 8, 2022

golang/go#51082 proposes to add new markup for Go documentation. Part of that is explicit syntax for linking to identifiers. We could flag references that do not resolve.

Suggested by @seankhliao

@dominikh dominikh added needs-decision We have to decide if this check is feasible and desirable new-check labels Feb 8, 2022
@dominikh dominikh changed the title stylecheck: flag doc references to nonexisting symbols stylecheck: flag doc references to nonexisting objects Feb 8, 2022
@thepudds
Copy link

thepudds commented Feb 19, 2022

Part of that is explicit syntax for linking to identifiers. We could flag references that do not resolve.

Hi @dominikh, if this was implemented, presumably it would be reasonable to also flag if a URL link in the comment does not have a corresponding link URL definition at the bottom? (In other words, no Go identifier or symbol involved, just a URL).

// For an introduction to this package, see the article
// “[JSON & Go].”
//
// [JSON and Go]: https://golang.org/doc/articles/json_and_go.html

(And maybe that is intended to be covered already -- I am just trying to be explicit).

@dominikh
Copy link
Owner Author

@thepudds Can we differentiate unresolved references from text which just wants to be enclosed in brackets and doesn't denote a link? Linking to identifiers has a number of restrictions to avoid false positives on godoc's end which would also aid us. For URLs, no such restrictions exist.

@thepudds
Copy link

thepudds commented Feb 19, 2022

Hi @dominikh, that’s a fair question. (And I see that you are of course right that the proposal only has the additional false positive safeguards for linking to identifiers).

Perhaps a more robust check might be to flag if a properly formatted and positioned link URL definition does not have a corresponding URL link in the comment.

The proposal already reformats those into a different group separated by a blank line, but that only helps if you have at least two total.

At least for me, flagging an accidentally out of sync link definition (due to a typo, a subsequent inconsistent edit, bad copy/paste, …) seems useful, so maybe one additional way to cut down on noise might be to only report if there is at least one piece of text in the comment enclosed in brackets that is not covered by some link definition at the bottom. Alternatively, it could just flag any unused link definition.

@dominikh
Copy link
Owner Author

I'll definitely explore these things when I write the check. Thanks for making me aware that URLs are also worth checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision We have to decide if this check is feasible and desirable new-check
Projects
None yet
Development

No branches or pull requests

2 participants