Skip to content

Ban unresolved dartdoc directives from HTML output - #62167

Merged
goderbauer merged 3 commits into
flutter:masterfrom
goderbauer:dartdocdirective
Jul 28, 2020
Merged

goderbauer merged 3 commits into
flutter:masterfrom
goderbauer:dartdocdirective

Conversation

@goderbauer

Copy link
Copy Markdown
Member

Description

Due to spelling mistakes (or other errors) the HTML of our dartdocs sometimes still contain unresolved dartdoc directives verbatim (e.g. {@foo x y}). This usually indicates an error, those should not be part of the final output. This PR adds a check that runs over the generated dartdocs to ensure that no unresolved directives are included in the output. It also fixes all unresolved directives in the framework.

Due to bugs in dartdoc (namely, dart-lang/dartdoc#1945 and dart-lang/dartdoc#2272) some unresolved directives will still appear in the output. The check contains exceptions for those. Once those issues are fixed, those exceptions will be removed.

Related Issues

Fixes #47652.
dart-lang/dartdoc#1945
dart-lang/dartdoc#2272

Tests

I added the following tests:

This entire thing is a test for our docs.

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@fluttergithubbot fluttergithubbot added p: material_ui material_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Jul 23, 2020
@fluttergithubbot

Copy link
Copy Markdown
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@goderbauer

Copy link
Copy Markdown
Member Author

It looks like this pull request may not have tests.

The entire thing is a test for our dart docs :P

Comment thread dev/tools/dartdoc_checker.dart Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't this eliminate most of the files?

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 eliminates class-level and library-level files. The majority of files are documentation for properties, which are getting checked. My hope is that we can get this fixed soon-ish on the dartdoc side.

Comment thread dev/tools/dartdoc_checker.dart Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about something like this instead? (and do use r'' strings).

Suggested change
final RegExp _pattern = RegExp('({@[^}\n]*}?)(?![^<>]*<\/code)');
final RegExp _pattern = RegExp(r'(<code[^<>]*>)(?!.*?<code[^<>]*>).*?({@[^}\n]*}).*?(<\/code>)');

And why do you have the ? after the }? are macros expected to not be terminated? I mean sure, if someone is misspelling them, they can also not terminate them, but that seems unlikely.

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.

Added r.

Since it is essentially free, I do want to catch the error where a macro is not terminated (or has been terminated with a ) instead of a } etc).

I don't fully understand the regex suggestion. Wouldn't that match things inside a code tag?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I wasn't thinking about the regex in the right way: my suggestion would only match inside of a code block. Please ignore it. :-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given this sort of error, do we want to just search for all words beginning with "@" outside of code blocks? Or is that too many false positives?

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.

Unfortunately, that has too many false positives. If that becomes a common source of error, we could also match on something like (@foo} and report an error for those.

@gspencergoog gspencergoog Jul 24, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I figured. OK.

@gspencergoog gspencergoog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@fluttergithubbot

Copy link
Copy Markdown
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite tool_tests-integration-linux has failed. Please fix the issues identified (or deflake) before re-applying this label.

@goderbauer
goderbauer merged commit e17a721 into flutter:master Jul 28, 2020
@goderbauer
goderbauer deleted the dartdocdirective branch July 28, 2020 22:26
Pragya007 pushed a commit to Pragya007/flutter that referenced this pull request Aug 11, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"@template" text visible in API docs

4 participants