Truncate macro ids, as for other symbols

This commit is contained in:
Daniel James 2017-10-30 16:47:51 +00:00
parent 34ad10b7dc
commit d2b0125d71
4 changed files with 33 additions and 13 deletions

View File

@ -3,7 +3,8 @@
<link linkend="foo_id1">foo</link>
<link linkend="FOO_id1">FOO</link>
<link linkend="bar">bar</link></synopsis>
<link linkend="bar">bar</link>
<link linkend="REALLY__id1">REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</link></synopsis>
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="foo_id1"><refmeta><refentrytitle>Macro foo</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>foo</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
</phrase>foo</synopsis></refsynopsisdiv><refsect1><title>Description</title>
@ -16,4 +17,8 @@
</phrase>bar</synopsis></refsynopsisdiv><refsect1><title>Description</title>
</refsect1></refentry>
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="REALLY__id1"><refmeta><refentrytitle>Macro REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
</phrase>REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</synopsis></refsynopsisdiv><refsect1><title>Description</title>
</refsect1></refentry>
</section>

View File

@ -1,14 +1,15 @@
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<section id="header.example_hpp"><title>Header &lt;<ulink url="../../example.hpp">example.hpp</ulink>&gt;</title><synopsis xmlns:xi="http://www.w3.org/2001/XInclude">
<link linkend="foo_id-1_1">foo</link>
<link linkend="FOO_id-1_2">FOO</link>
<link linkend="bar">bar</link></synopsis>
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="foo_id-1_1"><refmeta><refentrytitle>Macro foo</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>foo</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
<link linkend="foo_1_1">foo</link>
<link linkend="FOO_1_2">FOO</link>
<link linkend="bar">bar</link>
<link linkend="REALLY_LONG_MACRO_NAME_1_4">REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</link></synopsis>
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="foo_1_1"><refmeta><refentrytitle>Macro foo</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>foo</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
</phrase>foo</synopsis></refsynopsisdiv><refsect1><title>Description</title>
</refsect1></refentry>
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="FOO_id-1_2"><refmeta><refentrytitle>Macro FOO</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>FOO</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="FOO_1_2"><refmeta><refentrytitle>Macro FOO</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>FOO</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
</phrase>FOO</synopsis></refsynopsisdiv><refsect1><title>Description</title>
</refsect1></refentry>
@ -16,4 +17,8 @@
</phrase>bar</synopsis></refsynopsisdiv><refsect1><title>Description</title>
</refsect1></refentry>
<refentry xmlns:xi="http://www.w3.org/2001/XInclude" id="REALLY_LONG_MACRO_NAME_1_4"><refmeta><refentrytitle>Macro REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</refentrytitle><manvolnum>3</manvolnum></refmeta><refnamediv><refname>REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</refname><refpurpose/></refnamediv><refsynopsisdiv><synopsis><phrase role="comment">// In header: &lt;<link linkend="header.example_hpp">example.hpp</link>&gt;
</phrase>REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED</synopsis></refsynopsisdiv><refsect1><title>Description</title>
</refsect1></refentry>
</section>

View File

@ -19,4 +19,8 @@
<description>
</description>
</macro>
<macro name="REALLY_LONG_MACRO_NAME_WHICH_SHOULD_GET_TRUNCATED">
<description>
</description>
</macro>
</header>

View File

@ -111,12 +111,18 @@
</xsl:template>
<xsl:template match="macro" mode="generate.id">
<xsl:value-of select="@name"/>
<xsl:if test="count(key('named-entities',
translate(@name, $uppercase-letters, $lowercase-letters)))!=1">
<xsl:variable name="raw.id"><xsl:call-template name="object.id"/></xsl:variable>
<xsl:text>_</xsl:text>
<xsl:value-of select="translate($raw.id, '.', '_')"/>
</xsl:if>
<xsl:choose>
<xsl:when test="string-length(@name) &gt; $boost.max.id.part.length or
count(key('named-entities',
translate(@name, $uppercase-letters, $lowercase-letters)))!=1">
<xsl:variable name="raw.id"><xsl:call-template name="postfix.id"/></xsl:variable>
<xsl:value-of select="substring(@name, 1, $boost.max.id.part.length - string-length($raw.id) - 1)"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="$raw.id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>