@@ -27,21 +27,31 @@ var qdocVerbatim = map[string]struct{}{
2727 "raw" : {},
2828}
2929
30- // qdocSkipLine names the topic, context, and quoting commands whose whole
31- // line is markup: identifiers, file paths, and cross-references, not prose.
30+ // qdocSkipLine names the topic, context, quoting, build-system, and
31+ // conditional commands whose whole line is markup: identifiers, file paths,
32+ // cross-references, and expressions, not prose.
3233var qdocSkipLine = map [string ]struct {}{
3334 "annotatedlist" : {},
3435 "class" : {},
36+ "cmakecomponent" : {},
37+ "cmakepackage" : {},
38+ "cmaketargetitem" : {},
3539 "codeline" : {},
40+ "compareswith" : {},
3641 "contentspage" : {},
42+ "dontdocument" : {},
3743 "dots" : {},
44+ "else" : {},
45+ "endcompareswith" : {},
46+ "endif" : {},
3847 "enum" : {},
3948 "example" : {},
4049 "externalpage" : {},
4150 "fn" : {},
4251 "generatelist" : {},
4352 "group" : {},
4453 "headerfile" : {},
54+ "if" : {},
4555 "include" : {},
4656 "indexpage" : {},
4757 "ingroup" : {},
@@ -55,6 +65,7 @@ var qdocSkipLine = map[string]struct{}{
5565 "meta" : {},
5666 "module" : {},
5767 "namespace" : {},
68+ "nativetype" : {},
5869 "nextpage" : {},
5970 "noautolist" : {},
6071 "nonreentrant" : {},
@@ -69,12 +80,17 @@ var qdocSkipLine = map[string]struct{}{
6980 "qmlattachedsignal" : {},
7081 "qmlbasictype" : {},
7182 "qmlclass" : {},
83+ "qmlenum" : {},
7284 "qmlmethod" : {},
7385 "qmlmodule" : {},
7486 "qmlproperty" : {},
7587 "qmlsignal" : {},
88+ "qmlsingletontype" : {},
7689 "qmltype" : {},
7790 "qmlvaluetype" : {},
91+ "qtcmakepackage" : {},
92+ "qtcmaketargetitem" : {},
93+ "qtvariable" : {},
7894 "quotefile" : {},
7995 "quotefromfile" : {},
8096 "reentrant" : {},
@@ -88,8 +104,10 @@ var qdocSkipLine = map[string]struct{}{
88104 "skipuntil" : {},
89105 "snippet" : {},
90106 "startpage" : {},
107+ "tableofcontents" : {},
91108 "target" : {},
92109 "threadsafe" : {},
110+ "typealias" : {},
93111 "typedef" : {},
94112 "variable" : {},
95113 "wrapper" : {},
@@ -109,9 +127,11 @@ var (
109127 qdocBlockCmd = regexp .MustCompile (`^\s*\\([a-zA-Z0-9]+)\s*(.*)$` )
110128 // An inline command and its argument: `\c word` or `\c {some words}`,
111129 // with an optional [qualifier] for `\l`. A braced argument may wrap
112- // within its paragraph.
113- qdocInlineCmd = regexp .MustCompile (`\\([a-zA-Z0-9]+)\s*(\[[^\]\n]*\]\s*)?(\{[^{}]*\}|[^\s{][^\s]*)?` )
114- // The braced {text} that may follow a braced `\l` target.
130+ // within its paragraph. `\\` is an escaped backslash, matched first so
131+ // that the command that follows one is read as text.
132+ qdocInlineCmd = regexp .MustCompile (`\\\\|\\([a-zA-Z0-9]+)\s*(\[[^\]\n]*\]\s*)?(\{[^{}]*\}|[^\s{][^\s]*)?` )
133+ // The braced {text} that may follow a braced `\l` target or `\span`
134+ // attribute.
115135 qdocLinkText = regexp .MustCompile (`^\s*\{[^{}]*\}` )
116136)
117137
@@ -144,6 +164,13 @@ func qdocInline(text string) string {
144164 }
145165 out .WriteString (text [:loc [0 ]])
146166
167+ if loc [2 ] < 0 {
168+ // `\\` is a literal backslash, not a command.
169+ out .WriteString (`\` )
170+ text = text [loc [1 ]:]
171+ continue
172+ }
173+
147174 name := text [loc [2 ]:loc [3 ]]
148175 arg := ""
149176 if loc [6 ] >= 0 {
@@ -171,9 +198,20 @@ func qdocInline(text string) string {
171198 }
172199 }
173200 out .WriteString (`<a href="#">` + label + "</a>" )
201+ case "span" :
202+ // `\span {class="x"} {text}`: the attribute is markup, the
203+ // braced text that follows is prose.
204+ label := ""
205+ if m := qdocLinkText .FindString (rest ); m != "" {
206+ label = qdocArg (strings .TrimSpace (m ))
207+ rest = rest [len (m ):]
208+ }
209+ out .WriteString ("<span>" + label + "</span>" )
174210 case "image" , "inlineimage" :
175211 // The argument is a file name; a caption, if any, follows as
176212 // ordinary prose.
213+ case "unicode" :
214+ // The argument is a code point, not prose.
177215 default :
178216 // An unknown command is markup; whatever followed it is prose.
179217 rest = text [loc [3 ]:]
@@ -270,14 +308,24 @@ func (c *qdocConv) endItem() {
270308 top .inItem = false
271309}
272310
311+ // qdocBlankDelims blanks the comment delimiters of a standalone .qdoc file,
312+ // which a command or its prose may share a line with: `/*! \page index.html`.
313+ // They are replaced by spaces rather than removed so that a column in the
314+ // converted line is still a column in the source.
315+ func qdocBlankDelims (raw string ) string {
316+ if i := strings .Index (raw , "/*!" ); i >= 0 && strings .TrimSpace (raw [:i ]) == "" {
317+ raw = raw [:i ] + " " + raw [i + 3 :]
318+ }
319+ if i := strings .LastIndex (raw , "*/" ); i >= 0 && strings .TrimSpace (raw [i + 2 :]) == "" {
320+ raw = raw [:i ] + " " + raw [i + 2 :]
321+ }
322+ return raw
323+ }
324+
273325func (c * qdocConv ) line (raw string ) { //nolint:gocyclo // one case per command family
326+ raw = qdocBlankDelims (raw )
274327 trimmed := strings .TrimSpace (raw )
275328
276- // Comment delimiters, in both standalone .qdoc files and sources.
277- if trimmed == "/*!" || trimmed == "*/" || strings .HasPrefix (trimmed , "/*!" ) && strings .HasSuffix (trimmed , "*/" ) {
278- return
279- }
280-
281329 if c .verbatim != "" {
282330 if m := qdocBlockCmd .FindStringSubmatch (raw ); m != nil && m [1 ] == c .verbatim {
283331 c .verbatim = ""
0 commit comments