-
-
Notifications
You must be signed in to change notification settings - Fork 379
add URL recognition to Ddoc spec #1858
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
Conversation
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
FYI @s-ludwig |
@WalterBright: In dlang/dmd#7043 you stated that code like
|
@s-ludwig The recognition happens on the raw text. Macro invocations are part of that.
Yes. It must, as the entire Ddoc text is often in a macro.
No. https://github.com/dlang/dmd/blob/master/src/ddmd/doc.d#L1935 |
Rebased and set to auto-merge as this is now the behavior of DMD. |
spec/ddoc.dd
Outdated
@@ -542,12 +546,23 @@ Identifiers in documentation comments that are function parameters or are | |||
names that are in scope at the associated declaration are emphasized in | |||
the output. | |||
This emphasis can take the form of italics, boldface, a hyperlink, etc. | |||
How it is emphasized depends on what it is - a function parameter, type, | |||
How it is emphasized depends on what it is — a function parameter, type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a problem somewhere around the —
, because of which the Latex build fails the following rather cryptic error:
! Misplaced alignment tab character &.
l.24904 ...t is emphasized depends on what it is &
mdash; a function paramete...
?
! Emergency stop.
spec/ddoc.dd
Outdated
$(P | ||
URLs are sequences of characters starting with 'http://' or 'https://', | ||
continue with one or more characters from the set of letters, digits and | ||
`-_?=%&/+#~.`, and contain at least one `.`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the best preference here, the easiest way to fix -_?=%&/+#~.
is to put in a code block, otherwise sth. like '-_?=%$(AMP)/+#~.'
would also work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code blocks look much cleaner.
It looks like now the build is failing because it can't reach |
spec/ddoc.dd
Outdated
$(P | ||
URLs are sequences of characters starting with 'http://' or 'https://', | ||
continue with one or more characters from the set of letters, digits and | ||
`-_?=%&/+#~.`, and contain at least one `.`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @WalterBright Any updates w.r.t. @MetaLang 's request for changes? Let's get this moving along. |
Did @MetaLang 's request |
Just an afterthought: is there a way to suppress this URL recognition behaviour? Just an example off the top of my head, that perhaps we're documenting a URL parsing library, and the ddoc would like to give examples of URLs or URL snippets. It would be nice if there was a way to distinguish between these example URLs (that we don't want to generate a link for) vs. real URLs that we do want to generate a link for. |
P.S. In general, I'm wary when something is automated with no way to turn it off. I'm all for smart recognition of URLs, section headings, etc., but there needs to be a way to suppress this behaviour when the automatic behaviour is not desirable. I don't want to see this become yet another train wreck like the auto highlighting of keywords in plain text, that has led to underscore proliferation everywhere in the Phobos docs (and tons of wasted time churning through PRs that do nothing except prefix underscores to words that got highlighted when they shouldn't be). |
That's a good point, but I think it's something that can easily be added in a follow-up PR. |
$(H3 $(LNAME2 urls, URLs)) | ||
|
||
$(P | ||
URLs are sequences of characters starting with 'http://' or 'https://', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you need to add that the sequences are preceded by whitespace, otherwise asdhttp:// will be considered a URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ironically, github considers the above a URL!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I guess I'll approve...
Ah, one more thing - the macro should be different from |
Yes, please make it |
Here: #2127 |
Document enhancement dlang/dmd#7043