Skip to content

Should recognize generic syntax in plain text in dart docs rather than treating it as HTML #1250

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

Closed
Hixie opened this issue Sep 7, 2016 · 16 comments
Labels
customer-flutter Issues originating from important to Flutter P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@Hixie
Copy link
Contributor

Hixie commented Sep 7, 2016

The following comment:

/// This class specializes the interpolation of Tween<int> to be

...turns into the text "This class specializes the interpolation of Tween to be" because the <int> part is treated like HTML markup.

@Hixie Hixie added P1 A high priority bug; for example, a single project is unusable or has many test failures customer-flutter Issues originating from important to Flutter labels Sep 7, 2016
@astashov
Copy link
Contributor

How do we want it to be fixed?

  • We can try to not treat HTML markup in the comments at all
  • We can recognize if it's a valid HTML tag - then treat it as HTML, otherwise - escape it so it will be shown as text
  • We can check if there's a closing tag - if not, then it's a generic :)
  • Something else?

What do you think? /cc @devoncarew

@Hixie
Copy link
Contributor Author

Hixie commented Dec 20, 2016

Personally I'd be fine with not supporting HTML at all, except that we use it in a few places:

  • Element.updateChild has some <table> markup because markdown tables weren't working. This case would be handled fine by either having markdown tables or whitelisting table, tbody, thead, tr, th, td, etc. Note that there is markdown mixed in with the markup here.
  • material/icons.dart uses some crazy markup for various reasons. This case could be handled by allowing markup on any line that starts with a < (and ignoring any markdown on that line).

@Hixie
Copy link
Contributor Author

Hixie commented Dec 20, 2016

Don't check for a closing tag, those are sometimes optional in HTML (and indeed are omitted in both of the cases above).
Checking for a whitelist of tags would work so long as none of them match class names (like "int" or "Table", though case sensitivity could help with the latter case).

@Hixie
Copy link
Contributor Author

Hixie commented Dec 20, 2016

Hm, I just noticed that mixing markdown and markup in Element.updateChild isn't working. For tables I guess we really just want true markdown tables.

@astashov
Copy link
Contributor

This case could be handled by allowing markup on any line that starts with a < (and ignoring any markdown on that line

It seems like just having this would solve the problem described in this ticket, right?

@Hixie
Copy link
Contributor Author

Hixie commented Dec 21, 2016

Yeah that would be fine by me. We'll have to figure out what to do with the Element.updateChild case though.

@astashov
Copy link
Contributor

I will look at it.

@astashov
Copy link
Contributor

Actually, @Hixie, if you write it like this:

/// This class specializes the interpolation of [Tween<int>] to be

(i.e. in square brackets), it will look right. Would that solve the problem for you?

@Hixie
Copy link
Contributor Author

Hixie commented Dec 24, 2016

What does it hyperlink to?

@astashov
Copy link
Contributor

Tween class, if in scope. Nothing (will just be wrapped into <code>) - if it's not.

@Hixie
Copy link
Contributor Author

Hixie commented Dec 27, 2016

Sounds good to me.

In that case I guess the problem boils down to us detecting cases of invalid HTML in our dartdoc markdown.

@astashov
Copy link
Contributor

In that case I guess the problem boils down to us detecting cases of invalid HTML in our dartdoc markdown.

Umm, what for? Could you give an example?

@Hixie
Copy link
Contributor Author

Hixie commented Dec 27, 2016

To catch the cases where I incorrectly did things like Tween<int> instead of [Tween<int>]. :-)

@astashov
Copy link
Contributor

Oh, gotcha. So, basically it will be a whitelist of tags? And a warning in the console output if it's not in a whitelist?

@Hixie
Copy link
Contributor Author

Hixie commented Dec 27, 2016

Oh that would be amazing, yeah. I actually just meant that we'd run some HTML validator over the site, but if you can actually catch things at build time that'd be even better.

In general my dream is to get to a point where any time there's anything wrong with the docs (including any time we use [] cross-references but they don't work), we get an error in the PR that introduces the error so that we can deal with it. So yeah, a warning (which we could then fail the PR from) would be awesome.

@astashov
Copy link
Contributor

Right now I don't see any warning/error system in dartdoc, probably would be a good idea to add.
Like, if there's at least one warning, we will exit with the exit code 2, if there's at least one error, we'll exit with the exit code 1. If nothing - then 0. Or something like that.

astashov added a commit to astashov/dartdoc that referenced this issue Dec 29, 2016
@Hixie asked for warnings when the generics are "free-hanging", and not
wrapped into [] block (like Apple<Cat>, but not [Apple<Cat>]). This
commit adds those warnings. We try to find tags, not wrapped into
square brackets, which is not from the whitelist of possible HTML tags.

Also, now output all the warnings to the console:

* When there's a missing reference in the comments
* When there's ambiguous reference in the comments
* When there's "free-hanging" generics

But that generates TONS AND TONS of warnings when you e.g. generate Dart
SDK docs or Flutter docs. So, I've added a flag `--show-warnings`,
without it we won't show the warnings.
astashov added a commit to astashov/dartdoc that referenced this issue Dec 29, 2016
@Hixie asked for warnings when the generics are "free-hanging", and not
wrapped into [] block (like `Apple<Cat>`, but not `[Apple<Cat>]`). This
commit adds those warnings. We try to find the tags, which are not
wrapped into square brackets, which are not from the whitelist of
possible HTML tags.

Also, now output all the warnings to the console:

* When there's a missing reference in the comments
* When there're ambiguous reference in the comments
* When there're "free-hanging" generics

But that generates TONS AND TONS of warnings when you e.g. generate Dart
SDK docs or Flutter docs. So, I've added the flag `--show-warnings`,
without it we don't show the warnings.
keertip pushed a commit that referenced this issue Jan 3, 2017
* Add warnings for "free-hanging" generics in docs [#1250]

@Hixie asked for warnings when the generics are "free-hanging", and not
wrapped into [] block (like `Apple<Cat>`, but not `[Apple<Cat>]`). This
commit adds those warnings. We try to find the tags, which are not
wrapped into square brackets, which are not from the whitelist of
possible HTML tags.

Also, now output all the warnings to the console:

* When there's a missing reference in the comments
* When there're ambiguous reference in the comments
* When there're "free-hanging" generics

But that generates TONS AND TONS of warnings when you e.g. generate Dart
SDK docs or Flutter docs. So, I've added the flag `--show-warnings`,
without it we don't show the warnings.

* Address feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-flutter Issues originating from important to Flutter P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

2 participants