[libvirt] [PATCH] docs: Make anchors follow HTML5

Michal Privoznik posted 1 patch 4 years, 8 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/800ee22ea2087fcabb580ffed1e236e78c3103a0.1566980278.git.mprivozn@redhat.com
docs/api_extension.html.in | 12 ++++++------
docs/dbus.html.in          |  6 +++---
docs/devhelp/html.xsl      | 16 ++++++++--------
docs/genaclperms.pl        |  4 ++--
docs/hvsupport.pl          |  2 +-
docs/newapi.xsl            |  6 +++---
6 files changed, 23 insertions(+), 23 deletions(-)
[libvirt] [PATCH] docs: Make anchors follow HTML5
Posted by Michal Privoznik 4 years, 8 months ago
According to HTML specification, <a name=''> works in HTML4, but
<a id=''> works in both HTML4 and HTML5. This is followed even in
docs/page.xsl where HTML bookmark links are generated only for
those anchors which have @id attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

For instance, ToC at the following page doesn't work:

  https://libvirt.org/hvsupport.html

But after this patch the links are generated properly.

 docs/api_extension.html.in | 12 ++++++------
 docs/dbus.html.in          |  6 +++---
 docs/devhelp/html.xsl      | 16 ++++++++--------
 docs/genaclperms.pl        |  4 ++--
 docs/hvsupport.pl          |  2 +-
 docs/newapi.xsl            |  6 +++---
 6 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/docs/api_extension.html.in b/docs/api_extension.html.in
index 604c397c84..79e7913c1a 100644
--- a/docs/api_extension.html.in
+++ b/docs/api_extension.html.in
@@ -89,7 +89,7 @@
       separately.
     </p>
 
-    <h2><a name='publicapi'>Defining the public API</a></h2>
+    <h2><a id='publicapi'>Defining the public API</a></h2>
 
     <p>The first task is to define the public API.  If the new API
       involves an XML extension, you have to enhance the RelaxNG
@@ -119,7 +119,7 @@
       rework it as you go through the process of implementing it.
     </p>
 
-    <h2><a name='internalapi'>Defining the internal API</a></h2>
+    <h2><a id='internalapi'>Defining the internal API</a></h2>
 
     <p>
       Each public API call is associated with a driver, such as a host
@@ -146,7 +146,7 @@
       provide a <code>NULL</code> stub for the new function.
     </p>
 
-    <h2><a name='implpublic'>Implementing the public API</a></h2>
+    <h2><a id='implpublic'>Implementing the public API</a></h2>
 
     <p>
       Implementing the public API is largely a formality in which we wire up
@@ -179,7 +179,7 @@
 
     <p><code>src/libvirt-$MODULE.c</code></p>
 
-    <h2><a name='remoteproto'>Implementing the remote protocol</a></h2>
+    <h2><a id='remoteproto'>Implementing the remote protocol</a></h2>
 
     <p>
       Implementing the remote protocol is essentially a
@@ -187,7 +187,7 @@
       understood by referring to the existing code.
     </p>
 
-    <h3><a name='wireproto'>Defining the wire protocol format</a></h3>
+    <h3><a id='wireproto'>Defining the wire protocol format</a></h3>
 
     <p>
       Defining the wire protocol involves making additions to:
@@ -226,7 +226,7 @@
         src/remote/remote_protocol.h
     </code></p>
 
-    <h3><a name='rpcclient'>Implement the RPC client</a></h3>
+    <h3><a id='rpcclient'>Implement the RPC client</a></h3>
 
     <p>
       Implementing the RPC client uses the rpcgen generated .h files.
diff --git a/docs/dbus.html.in b/docs/dbus.html.in
index 6ff71d2770..4dfe4ca427 100644
--- a/docs/dbus.html.in
+++ b/docs/dbus.html.in
@@ -6,14 +6,14 @@
 
     <ul id="toc"></ul>
 
-    <h2><a name="description">Description</a></h2>
+    <h2><a id="description">Description</a></h2>
 
     <p>
       libvirt-dbus wraps libvirt API to provide a high-level object-oriented
       API better suited for dbus-based applications.
     </p>
 
-    <h2><a name="git">GIT source repository</a></h2>
+    <h2><a id="git">GIT source repository</a></h2>
     <p>
       The D-Bus bindings source code is maintained in a
       <a href="https://git-scm.com/">git</a> repository available on
@@ -32,7 +32,7 @@ git clone https://libvirt.org/git/libvirt-dbus.git
 <a href="https://libvirt.org/git/?p=libvirt-dbus.git">https://libvirt.org/git/?p=libvirt-dbus.git</a>
 </pre>
 
-    <h2><a name="usage">Usage</a></h2>
+    <h2><a id="usage">Usage</a></h2>
 
     <p>
       libvirt-dbus exports libvirt API using D-Bus objects with methods and
diff --git a/docs/devhelp/html.xsl b/docs/devhelp/html.xsl
index 9cdc049150..587cbfc1a9 100644
--- a/docs/devhelp/html.xsl
+++ b/docs/devhelp/html.xsl
@@ -173,7 +173,7 @@
   <xsl:template mode="details" match="struct">
     <xsl:variable name="name" select="string(@name)"/>
     <div class="refsect2" lang="en">
-    <h3><a name="{$name}">Structure </a><xsl:value-of select="$name"/></h3>
+    <h3><a id="{$name}">Structure </a><xsl:value-of select="$name"/></h3>
     <pre class="programlisting">
     <xsl:value-of select="@type"/><xsl:text> {
 </xsl:text>
@@ -214,7 +214,7 @@
   <xsl:template mode="details" match="typedef[@type != 'enum']">
     <xsl:variable name="name" select="string(@name)"/>
     <div class="refsect2" lang="en">
-    <h3><a name="{$name}">Typedef </a><xsl:value-of select="$name"/></h3>
+    <h3><a id="{$name}">Typedef </a><xsl:value-of select="$name"/></h3>
     <pre class="programlisting">
     <xsl:call-template name="dumptext">
       <xsl:with-param name="text" select="string(@type)"/>
@@ -236,7 +236,7 @@
   <xsl:template mode="details" match="variable">
     <xsl:variable name="name" select="string(@name)"/>
     <div class="refsect2" lang="en">
-    <h3><a name="{$name}">Variable </a><xsl:value-of select="$name"/></h3>
+    <h3><a id="{$name}">Variable </a><xsl:value-of select="$name"/></h3>
     <pre class="programlisting">
     <xsl:call-template name="dumptext">
       <xsl:with-param name="text" select="string(@type)"/>
@@ -258,7 +258,7 @@
   <xsl:template mode="details" match="typedef[@type = 'enum']">
     <xsl:variable name="name" select="string(@name)"/>
     <div class="refsect2" lang="en">
-    <h3><a name="{$name}">Enum </a><xsl:value-of select="$name"/></h3>
+    <h3><a id="{$name}">Enum </a><xsl:value-of select="$name"/></h3>
     <pre class="programlisting">
     <xsl:text>enum </xsl:text>
     <a href="#{$name}"><xsl:value-of select="$name"/></a>
@@ -267,7 +267,7 @@
     <xsl:for-each select="/api/symbols/enum[@type=$name]">
       <xsl:sort select="@value" data-type="number" order="ascending"/>
       <xsl:text>    </xsl:text>
-      <a name="{@name}"><xsl:value-of select="@name"/></a>
+      <a id="{@name}"><xsl:value-of select="@name"/></a>
       <xsl:if test="@value">
         <xsl:text> = </xsl:text>
 	<xsl:value-of select="@value"/>
@@ -295,7 +295,7 @@
   <xsl:template mode="details" match="macro">
     <xsl:variable name="name" select="string(@name)"/>
     <div class="refsect2" lang="en">
-    <h3><a name="{$name}">Macro </a><xsl:value-of select="$name"/></h3>
+    <h3><a id="{$name}">Macro </a><xsl:value-of select="$name"/></h3>
     <pre class="programlisting">
     <xsl:text>#define </xsl:text>
     <a href="#{$name}"><xsl:value-of select="$name"/></a>
@@ -342,7 +342,7 @@
     <xsl:variable name="tlen" select="string-length(return/@type)"/>
     <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/>
     <div class="refsect2" lang="en">
-    <h3><a name="{$name}"></a><xsl:value-of select="$name"/> ()</h3>
+    <h3><a id="{$name}"></a><xsl:value-of select="$name"/> ()</h3>
     <pre class="programlisting">
     <xsl:call-template name="dumptext">
       <xsl:with-param name="text" select="return/@type"/>
@@ -419,7 +419,7 @@
     <xsl:variable name="tlen" select="string-length(return/@type)"/>
     <xsl:variable name="blen" select="(($nlen + 8) - (($nlen + 8) mod 8)) + (($tlen + 8) - (($tlen + 8) mod 8))"/>
     <div class="refsect2" lang="en">
-    <h3><a name="{$name}"></a>Function type <xsl:value-of select="$name"/> </h3>
+    <h3><a id="{$name}"></a>Function type <xsl:value-of select="$name"/> </h3>
     <pre class="programlisting">
     <xsl:call-template name="dumptext">
       <xsl:with-param name="text" select="return/@type"/>
diff --git a/docs/genaclperms.pl b/docs/genaclperms.pl
index 34c526021c..e20b4c11c3 100755
--- a/docs/genaclperms.pl
+++ b/docs/genaclperms.pl
@@ -84,7 +84,7 @@ foreach my $object (sort { $a cmp $b } keys %perms) {
     my $class = $class{$object};
     my $olink = lc "object_" . $object;
     print <<EOF;
-<h3><a name="$olink">$class</a></h3>
+<h3><a id="$olink">$class</a></h3>
 <table class="acl">
   <thead>
     <tr>
@@ -106,7 +106,7 @@ EOF
 
         print <<EOF;
     <tr>
-      <td><a name="$plink">$perm</a></td>
+      <td><a id="$plink">$perm</a></td>
       <td>$description</td>
     </tr>
 EOF
diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
index 4f4d86fbf1..494b8a27ec 100755
--- a/docs/hvsupport.pl
+++ b/docs/hvsupport.pl
@@ -364,7 +364,7 @@ when it was removed is also mentioned (highlighted in
 EOF
 
     foreach my $grp (sort { $a cmp $b } keys %groups) {
-    print "<h2><a name=\"$grp\">", $groupheaders{$grp}, "</a></h2>\n";
+    print "<h2><a id=\"$grp\">", $groupheaders{$grp}, "</a></h2>\n";
     print <<EOF;
 <table class="top_table">
 <thead>
diff --git a/docs/newapi.xsl b/docs/newapi.xsl
index 4c7b241659..ca8c703d5c 100644
--- a/docs/newapi.xsl
+++ b/docs/newapi.xsl
@@ -258,7 +258,7 @@
       </xsl:call-template>
     </span>
     <xsl:text> </xsl:text>
-    <a name="{@name}"></a>
+    <a id="{@name}"></a>
     <xsl:value-of select="@name"/>
     <xsl:text>
 </xsl:text>
@@ -281,7 +281,7 @@
           </xsl:call-template>
         </span>
 	<xsl:text> </xsl:text>
-	<a name="{$name}"><xsl:value-of select="$name"/></a>
+	<a id="{$name}"><xsl:value-of select="$name"/></a>
 	<xsl:text>
 </xsl:text>
       </xsl:otherwise>
@@ -320,7 +320,7 @@
         <xsl:for-each select="/api/symbols/enum[@type = $name]">
           <xsl:sort select="@value" data-type="number" order="ascending"/>
           <tr>
-            <td><a name="{@name}"><xsl:value-of select="@name"/></a></td>
+            <td><a id="{@name}"><xsl:value-of select="@name"/></a></td>
             <td><xsl:text> = </xsl:text></td>
             <xsl:choose>
               <xsl:when test="@info != ''">
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: Make anchors follow HTML5
Posted by Daniel P. Berrangé 4 years, 8 months ago
On Wed, Aug 28, 2019 at 10:18:45AM +0200, Michal Privoznik wrote:
> According to HTML specification, <a name=''> works in HTML4, but
> <a id=''> works in both HTML4 and HTML5. This is followed even in
> docs/page.xsl where HTML bookmark links are generated only for
> those anchors which have @id attribute.

I'm pretty sure we had tried 'id' in our docs a long time ago
and hit some problem, but I've not yet found record of what
it was....

That change itself looks ok, but I want to try & find the history
of why we didn't do this before

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: Make anchors follow HTML5
Posted by Daniel P. Berrangé 4 years, 8 months ago
On Wed, Aug 28, 2019 at 10:48:59AM +0100, Daniel P. Berrangé wrote:
> On Wed, Aug 28, 2019 at 10:18:45AM +0200, Michal Privoznik wrote:
> > According to HTML specification, <a name=''> works in HTML4, but
> > <a id=''> works in both HTML4 and HTML5. This is followed even in
> > docs/page.xsl where HTML bookmark links are generated only for
> > those anchors which have @id attribute.
> 
> I'm pretty sure we had tried 'id' in our docs a long time ago
> and hit some problem, but I've not yet found record of what
> it was....

Seems I was remembering the wrong way around :-)

  commit 4e42ff6b7e1b5dc2911075a3eb7b86cd2075cfd3
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Jul 26 15:52:42 2017 +0100

    docs: switch to using 'id' attribute instead of 'name' for links
    
    The 'name' attribute on <a...> elements is deprecated in favour
    of the 'id' attribute which is allowed on any element. HTML5
    drops 'name' support entirely.
    
    Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

and we're obviously not doing a very good job at avoiding
use of 'name' since then, as we've also had


  commit d89fa8306e97492d3c54875a3665a5fd4d310010
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Wed Aug 23 13:55:01 2017 +0200

    docs: Define anchors correctly in pci-hotplug
    
    HTML5 obsoletes the 'name' attribute in favor of 'id',
    and our TOC generator apparently follows the recommendation
    to the letter, resulting in a broken TOC if you use the
    old-school attribute.
    
    Signed-off-by: Andrea Bolognani <abologna@redhat.com>


commit 5726e4723473d047977db414b027de6e3d19bed8
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Aug 15 10:14:08 2019 +0200

    docs: Make anchors in API html files clickable/linkable
    
    Use 'id' instead of 'name' for anchors which adds the hidden clickable
    headerlink helper so it's way simpler to link to a specific part of the
    docs.
    
    Signed-off-by: Peter Krempa <pkrempa@redhat.com>
    Reviewed-by: Ján Tomko <jtomko@redhat.com>


So perhaps we need a syntax-check  rule added to blacklist name=
in the docs directory.

In any case

 Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: Make anchors follow HTML5
Posted by Michal Privoznik 4 years, 8 months ago
On 8/28/19 12:14 PM, Daniel P. Berrangé wrote:
> So perhaps we need a syntax-check  rule added to blacklist name=
> in the docs directory.

I'll try and see how strong my RE skills are.

> 
> In any case
> 
>   Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Thanks, I've pushed this. Possible syntax-check is to follow.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: Make anchors follow HTML5
Posted by Michal Privoznik 4 years, 8 months ago
On 8/28/19 11:48 AM, Daniel P. Berrangé wrote:
> On Wed, Aug 28, 2019 at 10:18:45AM +0200, Michal Privoznik wrote:
>> According to HTML specification, <a name=''> works in HTML4, but
>> <a id=''> works in both HTML4 and HTML5. This is followed even in
>> docs/page.xsl where HTML bookmark links are generated only for
>> those anchors which have @id attribute.
> 
> I'm pretty sure we had tried 'id' in our docs a long time ago
> and hit some problem, but I've not yet found record of what
> it was....
> 
> That change itself looks ok, but I want to try & find the history
> of why we didn't do this before

Fair enough. But even currently we use a mixture of 'name' and 'id' 
(with only the latter working properly for page.xsl).

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list