D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7687 - Ddoc should be able to generate "Jump to" links
Summary: Ddoc should be able to generate "Jump to" links
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL: http://dlang.org/phobos/std_array.html
Keywords: ddoc
Depends on:
Blocks:
 
Reported: 2012-03-11 10:33 UTC by Stewart Gordon
Modified: 2024-12-13 17:59 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Stewart Gordon 2012-03-11 10:33:25 UTC
Look at almost any page in the D2 Phobos docs.

If you have JavaScript enabled, you'll see that just after loading the page it adds a set of "Jump to:" links.

The code to do this has been made part of the Phobos Ddoc template.  It works by scanning the document for anchors and then listing them.

This is ridiculous.  What was the point of writing this JS code to get around a limitation of Ddoc, rather than fixing the limitation?

Ddoc should be able to generate this list of links itself.  This way, it would work regardless of whether the user has JS enabled.

Moreover, it would be good to give the user of Ddoc the choice of listing only module-level symbols or all documented symbols in the module.
Comment 1 Nick Treleaven 2014-12-24 16:59:11 UTC
Stewart Gordon from comment #0)
> This is ridiculous.  What was the point of writing this JS code to get
> around a limitation of Ddoc, rather than fixing the limitation?

Using JS is much easier than extending dmd as long as dmd uses a subset of C++. 

> Moreover, it would be good to give the user of Ddoc the choice of listing
> only module-level symbols or all documented symbols in the module.

I've made a pull for Issue 5136 which (essentially) solves this.
Comment 2 Stewart Gordon 2014-12-25 23:56:09 UTC
(In reply to Nick Treleaven from comment #1)
> Using JS is much easier than extending dmd as long as dmd uses a subset of
> C++. 

I have trouble believing it can be this difficult, given that the compiler must rely on quite complex data structures anyway.  What particular C++ feature would make implementing this feature easier if only it were in the subset that DMD is written in?
Comment 3 Nick Treleaven 2014-12-27 11:47:38 UTC
Using JS is easier than C++, whatever the subset.
Comment 4 Stewart Gordon 2014-12-27 19:09:54 UTC
So why wasn't the whole of DMD written in JS? :)

Seriously ... so you mean that Walter couldn't be bothered at the time to spend the time working out how to improve DMD, so for the meantime he just wrote this JS hack?
Comment 5 Nick Treleaven 2014-12-30 17:15:14 UTC
I was talking about for HTML generation. At the time the JS was first added, I don't think ddoc was in a good state, it has since improved significantly.
Comment 6 Stewart Gordon 2015-01-30 12:12:35 UTC
(In reply to Nick Treleaven from comment #5)
> I was talking about for HTML generation. At the time the JS was first added,
> I don't think ddoc was in a good state, it has since improved significantly.

But Ddoc isn't an HTML generator.  It's a macro-based system capable of generating documentation in a variety of formats.
Comment 7 Nick Treleaven 2015-01-30 12:41:12 UTC
You asked why JS was used, I explained. Please implement this if you like.
Comment 8 Doug Nickerson 2015-05-31 03:38:24 UTC
More minor, but whenever or however "Jump to" links are updated in the future, I noticed the ordering seems to be off:
If there are more than 9 overloads, the Jump to links read:
"10 11 2 3 4 5 6 7 8 9"
In other words, seems to be sorted lexicographically by the string value rather than numerically by the index value.
An example of this can be seen at: http://dlang.org/phobos/std_conv.html#.toImpl
Comment 9 Stewart Gordon 2015-06-09 11:40:39 UTC
(In reply to Doug Nickerson from comment #8)
> More minor, but whenever or however "Jump to" links are updated in the
> future, I noticed the ordering seems to be off:

This bug report is about the shortcoming in Ddoc's capabilities.  Any bug in dlang.org's JS workaround is a separate issue, so I think it should have a separate bug report.  Though it's useful to have this note here to make sure that it isn't overlooked when implementing the feature in Ddoc.

Of course, once this one is implemented, the bug with the JS workaround will become a non-issue.
Comment 10 dlangBugzillaToGithub 2024-12-13 17:59:02 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17543

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB