Skip to content
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

Bad codegen for methods implemented by multiple classes #14

Closed
jsoref opened this issue Jun 24, 2016 · 6 comments
Closed

Bad codegen for methods implemented by multiple classes #14

jsoref opened this issue Jun 24, 2016 · 6 comments

Comments

@jsoref
Copy link

jsoref commented Jun 24, 2016

This code generates multiple id= for a given thing. id= needs to be unique within a document...

multi sub node2html(Pod::Heading $node) {
    Debug { note colored("Heading node2html called for ", "bold") ~ $node.gist };
    my $lvl = min($node.level, 6); #= HTML only has 6 levels of numbered headings
    my %escaped = (
        id => escape_id(node2rawtext($node.contents)),
        html => node2inline($node.contents),
    );

    %escaped<uri> = uri_escape %escaped<id>;

    @indexes.push: Pair.new(key => $lvl, value => %escaped);

    return sprintf('<h%d id="%s">', $lvl, %escaped<id>)
                ~ qq[<a class="u" href="#___top" title="go to top of document">]
                    ~ %escaped<html>
                ~ qq[</a>]
            ~ qq[</h{$lvl}>\n];
}

https://doc.perl6.org/routine/new.html

  <li class="indexItem indexItem1"><a href="#class_Thread">class Thread</a></li>
  <ol class="indexList indexList2">
    <li class="indexItem indexItem2"><a href="#method_new"><a href="/routine/new#class_Thread">method new</a></a></li>
  </ol>
  <li class="indexItem indexItem1"><a href="#class_Version">class Version</a></li>
  <ol class="indexList indexList2">
    <li class="indexItem indexItem2"><a href="#method_new"><a href="/routine/new#class_Version">method new</a></a></li>
  </ol>
</ol>
</nav>
<p>Documentation for routine new, assembled from the following types:</p>
<h1 id="class_Mu"><a class="u" href="#___top" title="go to top of document">class Mu</a></h1>
<p>From <a href="/type/Mu#new">Mu</a></p>
<h2 id="method_new"><a class="u" href="#___top" title="go to top of document"><a href="/routine/new#class_Mu">method new</a></a></h2>
<pre>multi method new(*%attrinit)</pre>
<p>Default method for constructing (create + initialize) new objects of a class. This method expects only named arguments which are then used to initialize attributes w
ith accessors of the same name.</p>
<p>Classes may provide their own <code>new</code> method to override this default.</p>
<p><code>new</code> triggers an object construction mechanism that calls submethods named <code>BUILD</code> in each class of an inheritance hierarchy, if they exist. S
ee <a href="/language/objects#Object
Construction">the documentation on object construction</a> for more information.</p>
<h1 id="class_Backtrace"><a class="u" href="#___top" title="go to top of document">class Backtrace</a></h1>
<p>From <a href="/type/Backtrace#new">Backtrace</a></p>
<h2 id="method_new"><a class="u" href="#___top" title="go to top of document"><a href="/routine/new#class_Backtrace">method new</a></a></h2>
<p>Defined as:</p>
<pre>proto method new(*@, *%) {*}
multi method new()</pre>
<p>Usage:</p>
@ahalbert
Copy link

ahalbert commented Sep 10, 2016

After looking into this, I'm not sure this is a bug. It's been fixed by changing the links in the pod to (Type)_routine_new? If the pod file uses the same id for each one, shouldn't the html reflect that?

@ahalbert
Copy link

@zoffixznet do we know what needs to be done for this?

@zoffixznet
Copy link

Unsure. I closed-reopened by accident.

@jsoref
Copy link
Author

jsoref commented Mar 8, 2017

@ahalbert : technically id= is required to be unique in html, so any html generator that violates this rule is buggy.

@JJ
Copy link

JJ commented Mar 9, 2018

It might have been fixed or it's no longer an issue. No errors of that kind in that page now: https://validator.w3.org/nu/?doc=https%3A%2F%2Fdocs.perl6.org%2Froutine%2Fnew.html

@JJ
Copy link

JJ commented Mar 9, 2018

It's no longer an issue, probably due to change either in $node.contents or in node2rawtext. I close it now.

@JJ JJ closed this as completed Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants