Bug 6017 – std.algorithm.remove has a wrong link

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-16T07:47:00Z
Last change time
2014-07-19T01:18:53Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-05-16T07:47:06Z
This: http://d-programming-language.org/phobos/std_algorithm.html#remove points to the enum EditOp; instead of the function remove().
Comment #1 by kennytm — 2011-05-16T08:19:59Z
It's not technically wrong as the enum value's name is really 'EditOp.remove'... Perhaps those enum values shouldn't be linked.
Comment #2 by issues.dlang — 2011-05-16T08:37:43Z
The way that ddoc generates links needs to be completely rewritten. It needs to be hierarchal, but it's not at all. It acts like it's just linking in a set of free functions, and I believe that it links in the first symbol with a particular name, so if you have multiple documented symbols with the same name, then it's always the first one which gets linked in, regardless of whether that's the one which would be most usefully linked. I do think that having EditOp.remove linked is of value. But the links should be arranged in such a way that their hierarchy is clear, which would mean that the link would clearly be associated with EditOp and that the remove function would have its own link. I believe that this is really a fundamental ddoc problem and not a website problem at all. And I think that the table tha std.algorithm has now is as close to a fix as you're going to get any time soon.
Comment #3 by dlang-bugzilla — 2011-05-16T10:29:58Z
Wouldn't the problem be solved simpler by forcing it to generate unique anchor names for identifiers? I'm not sure how to understand Jonathan's comment about this, but I don't think DDoc actually thinks the two "remove"s are the same identifier.
Comment #4 by issues.dlang — 2011-05-16T10:39:26Z
Ddoc always generates a link to the first identifier with a given name. How it does that, I don't know. But it makes no attempt to make the links represent any kind of hierarchy. They're purely based on the base names of identifiers and completely ignore whether a particular identifier is actually an enum value or a member of a class or struct. It's designed as if everything were a free function. The way that the links are generated is far too simplistic and needs to be redesigned. In this case, both an enum value and a function have the same name. The enum happens to be first on the page, so it gets the link.
Comment #5 by dlang-bugzilla — 2011-05-16T10:40:49Z
My suggestion was to simply give one of them the anchor name "remove_2", or something like that.
Comment #6 by issues.dlang — 2011-05-16T10:52:51Z
They do need unique anchor names, but those anchor names should probably include the hiercharchy in some manner rather than simply having numbers tagged onto them - e.g. #EditOp__remove and #remove. The core problem is that ddoc doesn't care about anything other than the base identifier name. It makes no attempt to worry about the hiercharchy or about duplicate names. And honestly, it shouldn't have to worry about duplicate names, because duplicate names are illegal in the actual code. The duplication occurs because it's effectively treating all of the identifiers as if they were at module-level. Regardless, unique anchor names will be necessary. But I don't think that simply tacking on numbers is the right way to go about it. The fundamental problem needs to be solved. If you want to see a really bad example of the problem, looke at std.datetime. Several structs in there have the same function name, and the links become pretty useless.
Comment #7 by dlang-bugzilla — 2011-05-16T10:56:42Z
Yeah, I never said that this is a GOOD solution, but it's a quick and dirty one, and it'll allow linking to stuff in StackOverflow answers until someone fixes it properly ;) > Several structs in there have the same function name, and the links become pretty useless. Hmm, so what should be done about this? Serialize the function signature into the anchor name?
Comment #8 by issues.dlang — 2011-05-16T11:11:48Z
I don't think that we should be linking to every function overload, so the function signature isn't really the issue. It's the hierarchy. So, that needs to end up in the link somehow. So, for instance, if you took the year property that Date, DateTime, and SysTime have in std.datetime, you'd need something like #Date__year, #DateTime__year, and #SysTime__year. It would have to understand the hierarchy and concatenate the pieces of the hiearchy in some manner. __ makes some sense since it's unlikely to ever be the case that you'll end up with underscores at the beginning and/or end of identifiers such that the resulting anchor would conflict with the anchor of an identifier, but exactly what would be picked isn't necessarily all that important. It just needs to be unlikely to result in anchor names which conflict with other anchor names.
Comment #9 by dlang-bugzilla — 2011-05-16T11:17:40Z
> __ makes some sense since it's unlikely to ever be the case that you'll > end up with underscores at the beginning and/or end of identifiers such that You can put periods in anchor names (MediaWiki uses them to escape other characters, for example), so there's no need for underscores.
Comment #10 by issues.dlang — 2011-05-16T11:24:05Z
Ah. I didn't know that. I wrongly assumed that it wouldn't. That solves the problem quite nicely then. The obvious solution is then to represent the hiearchy directly. So, remove gets the anchor #EditOp.remove.
Comment #11 by issues.dlang — 2012-01-01T15:36:08Z
*** Issue 7195 has been marked as a duplicate of this issue. ***
Comment #12 by eco — 2012-03-11T15:15:42Z
Adam D. Ruppe has a pull request that includes a fix for this. https://github.com/D-Programming-Language/dmd/pull/770
Comment #13 by andrej.mitrovich — 2014-04-23T13:13:17Z
This seems to be fixed locally thanks to https://github.com/D-Programming-Language/dmd/pull/1174 and the updated 'MYREF' macro in std.algorithm, but the changes are not yet synced with the server, it currently points to: http://dlang.org/phobos/std_algorithm.html#remove Instead of: http://dlang.org/phobos/std_algorithm.html#.remove
Comment #14 by eco — 2014-06-24T19:46:32Z
*** Issue 11575 has been marked as a duplicate of this issue. ***
Comment #15 by hsteoh — 2014-06-24T20:11:04Z
Has the dlang.org docs been updated to document $DDOC_ANCHOR?
Comment #16 by hsteoh — 2014-06-24T20:52:35Z
Pull 1174 does *not* fix the problem, unfortunately. :-( Struct members still show up as global names rather than qualified with the containing struct name.
Comment #17 by hsteoh — 2014-06-24T21:15:46Z
Correction: pull 1174 fixes the problem for non-template members, but members of template structs, etc., still show up as top-level symbols.
Comment #18 by hsteoh — 2014-06-24T22:29:44Z
I've found the reason: emitAnchorName() is unable to find the parent symbol of a template member because the .parent pointer is only set when semantic is run, but at the time of ddoc generation, the template may not even be instantiated yet, so all the .parent pointers of the member DSymbol's are NULL.
Comment #19 by hsteoh — 2014-06-25T00:32:59Z
Found the fix: https://github.com/D-Programming-Language/dmd/pull/3693 Unfortunately, it seems to be unrelated to the specific issue in this bug; see instead: issue #10366.
Comment #20 by hsteoh — 2014-07-19T01:18:53Z
Fixed in git HEAD (as currently shown on dlang.org under the Phobos prerelease section).