1<?xml version="1.0" encoding="utf-8"?> 2<!-- 3 Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com> 4 5 Distributed under the Boost Software License, Version 1.0. 6 (See accompanying file LICENSE_1_0.txt or copy at 7 http://www.boost.org/LICENSE_1_0.txt) 8 --> 9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 10 version="1.0"> 11 <xsl:include href="annotation.xsl"/> 12 <xsl:include href="template.xsl"/> 13 <xsl:include href="function.xsl"/> 14 <xsl:include href="type.xsl"/> 15 <xsl:include href="source-highlight.xsl"/> 16 <xsl:include href="utility.xsl"/> 17 <xsl:include href="lookup.xsl"/> 18 <xsl:include href="library.xsl"/> 19 <xsl:include href="index.xsl"/> 20 <xsl:include href="error.xsl"/> 21 <xsl:include href="macro.xsl"/> 22 <xsl:include href="testing/testsuite.xsl"/> 23 <xsl:include href="caramel/concept2docbook.xsl"/> 24 25 <xsl:template name="namespace-synopsis"> 26 <xsl:param name="indentation" select="0"/> 27 <!-- Open namespace--> 28 <xsl:call-template name="indent"> 29 <xsl:with-param name="indentation" select="$indentation"/> 30 </xsl:call-template> 31 <xsl:call-template name="source-highlight"> 32 <xsl:with-param name="text" select="concat('namespace ',@name, ' {')"/> 33 </xsl:call-template> 34 35 <!-- Emit namespace types --> 36 <xsl:apply-templates select="class|class-specialization| 37 struct|struct-specialization| 38 union|union-specialization| 39 typedef|enum|data-member" mode="synopsis"> 40 <xsl:with-param name="indentation" select="$indentation + 2"/> 41 </xsl:apply-templates> 42 43 <!-- Emit namespace functions --> 44 <xsl:apply-templates 45 select="free-function-group|function|overloaded-function" 46 mode="synopsis"> 47 <xsl:with-param name="indentation" select="$indentation + 2"/> 48 </xsl:apply-templates> 49 50 <!-- Emit namespaces --> 51 <xsl:apply-templates select="namespace" mode="synopsis"> 52 <xsl:with-param name="indentation" select="$indentation + 2"/> 53 </xsl:apply-templates> 54 55 <!-- Close namespace --> 56 <xsl:text> </xsl:text> 57 <xsl:call-template name="indent"> 58 <xsl:with-param name="indentation" select="$indentation"/> 59 </xsl:call-template> 60 <xsl:call-template name="highlight-text"> 61 <xsl:with-param name="text" select="'}'"/> 62 </xsl:call-template> 63 </xsl:template> 64 65 <!-- Emit namespace synopsis --> 66 <xsl:template match="namespace" mode="synopsis"> 67 <xsl:param name="indentation" select="0"/> 68 69 <xsl:choose> 70 <xsl:when test="count(ancestor::namespace)=0"> 71 <xsl:call-template name="namespace-synopsis"> 72 <xsl:with-param name="indentation" select="$indentation"/> 73 </xsl:call-template> 74 </xsl:when> 75 <xsl:otherwise> 76 <xsl:text> </xsl:text> 77 <xsl:call-template name="namespace-synopsis"> 78 <xsl:with-param name="indentation" select="$indentation"/> 79 </xsl:call-template> 80 </xsl:otherwise> 81 </xsl:choose> 82 </xsl:template> 83 84 <!-- Emit namespace reference --> 85 <xsl:template match="namespace" mode="reference"> 86 <xsl:apply-templates select="namespace|free-function-group" 87 mode="reference"> 88 <xsl:with-param name="indentation" select="0"/> 89 </xsl:apply-templates> 90 <xsl:apply-templates select="class|class-specialization| 91 struct|struct-specialization| 92 union|union-specialization|enum|function| 93 overloaded-function|data-member|typedef" 94 mode="namespace-reference"/> 95 </xsl:template> 96 97 <!-- Eat extra documentation when in the synopsis or reference sections --> 98 <xsl:template match="para|section" mode="synopsis"/> 99 <xsl:template match="para|section" mode="reference"/> 100 101 <xsl:template name="find-wrap-point"> 102 <xsl:param name="text"/> 103 <xsl:param name="prefix"/> 104 <xsl:param name="result" select="0"/> 105 <xsl:param name="default" select="$max-columns - string-length($prefix)"/> 106 <xsl:variable name="s" select="substring($text, 2)"/> 107 <xsl:variable name="candidate"> 108 <xsl:choose> 109 <xsl:when test="contains($s, ' ')"> 110 <xsl:value-of select="string-length(substring-before($s, ' ')) + 1"/> 111 </xsl:when> 112 <xsl:otherwise> 113 <xsl:value-of select="string-length($text)"/> 114 </xsl:otherwise> 115 </xsl:choose> 116 </xsl:variable> 117 <xsl:choose> 118 <xsl:when test="string-length($prefix) + $result + $candidate <= $max-columns"> 119 <xsl:call-template name="find-wrap-point"> 120 <xsl:with-param name="text" select="substring($text, $candidate + 1)"/> 121 <xsl:with-param name="prefix" select="$prefix"/> 122 <xsl:with-param name="result" select="$result + $candidate"/> 123 <xsl:with-param name="default" select="$result + $candidate"/> 124 </xsl:call-template> 125 </xsl:when> 126 <xsl:otherwise> 127 <xsl:value-of select="$default"/> 128 </xsl:otherwise> 129 </xsl:choose> 130 </xsl:template> 131 132 <xsl:template name="wrap-comment"> 133 <xsl:param name="prefix"/> 134 <xsl:param name="text"/> 135 <xsl:choose> 136 <xsl:when test="string-length($prefix) + string-length($text) <= $max-columns"> 137 <xsl:value-of select="$text"/> 138 </xsl:when> 139 <xsl:otherwise> 140 <xsl:variable name="size"> 141 <xsl:call-template name="find-wrap-point"> 142 <xsl:with-param name="prefix" select="$prefix"/> 143 <xsl:with-param name="text" select="$text"/> 144 </xsl:call-template> 145 </xsl:variable> 146 <xsl:value-of select="substring($text, 1, $size)"/> 147 <xsl:text> </xsl:text> 148 <xsl:value-of select="$prefix"/> 149 <xsl:call-template name="wrap-comment"> 150 <xsl:with-param name="prefix" select="$prefix"/> 151 <xsl:with-param name="text" select="normalize-space(substring($text, $size + 1))"/> 152 </xsl:call-template> 153 </xsl:otherwise> 154 </xsl:choose> 155 </xsl:template> 156 157 <!-- Comment mode tries to wipe out any extra spacing in the output --> 158 <xsl:template match="purpose" mode="comment"> 159 <xsl:param name="wrap" select="false()"/> 160 <xsl:param name="prefix"/> 161 <xsl:apply-templates mode="comment"> 162 <xsl:with-param name="wrap" 163 select="$wrap and count(text()|*) = 1"/> 164 <xsl:with-param name="prefix" select="$prefix"/> 165 </xsl:apply-templates> 166 </xsl:template> 167 168 <xsl:template match="simpara|para" mode="comment"> 169 <xsl:param name="wrap" select="false()"/> 170 <xsl:param name="prefix"/> 171 <xsl:apply-templates select="text()|*" mode="comment"> 172 <xsl:with-param name="wrap" 173 select="$wrap and count(text()|*) = 1"/> 174 <xsl:with-param name="prefix" select="$prefix"/> 175 </xsl:apply-templates> 176 </xsl:template> 177 178 <xsl:template match="text()" mode="comment"> 179 <xsl:param name="wrap" select="false()"/> 180 <xsl:param name="prefix"/> 181 <xsl:variable name="stripped" select="normalize-space(.)"/> 182 <xsl:choose> 183 <xsl:when test="$wrap"> 184 <xsl:call-template name="wrap-comment"> 185 <xsl:with-param name="prefix" select="$prefix"/> 186 <xsl:with-param name="text" select="$stripped"/> 187 </xsl:call-template> 188 </xsl:when> 189 <xsl:otherwise> 190 <xsl:value-of select="."/> 191 </xsl:otherwise> 192 </xsl:choose> 193 </xsl:template> 194 195 <xsl:template match="*" mode="comment"> 196 <xsl:apply-templates select="." mode="annotation"/> 197 </xsl:template> 198</xsl:stylesheet> 199