comment-xml-schema.rng 15.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
<?xml version="1.0" encoding="UTF-8"?>

<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

  <start>
    <choice>
      <!-- Everything else not explicitly mentioned below. -->
      <ref name="Other" />

      <ref name="Function" />
      <ref name="Class" />
      <ref name="Variable" />
      <ref name="Namespace" />
      <ref name="Typedef" />
      <ref name="Enum" />
    </choice>
  </start>

  <define name="Other">
    <element name="Other">
      <ref name="attrSourceLocation" />
      <ref name="Name" />
      <optional>
        <ref name="USR" />
      </optional>
      <optional>
        <ref name="Headerfile" />
      </optional>
      <optional>
        <ref name="Declaration" />
      </optional>
      <optional>
        <ref name="Abstract" />
      </optional>
      <optional>
        <ref name="TemplateParameters" />
      </optional>
      <optional>
        <ref name="Parameters" />
      </optional>
      <optional>
        <ref name="ResultDiscussion" />
      </optional>
      <optional>
        <ref name="Discussion" />
      </optional>
    </element>
  </define>

  <define name="Function">
    <element name="Function">
      <optional>
        <attribute name="templateKind">
          <choice>
            <value>template</value>
            <value>specialization</value>
          </choice>
        </attribute>
      </optional>
      <ref name="attrSourceLocation" />

      <optional>
        <attribute name="isInstanceMethod">
          <data type="boolean" />
        </attribute>
      </optional>
      <optional>
        <attribute name="isClassMethod">
          <data type="boolean" />
        </attribute>
      </optional>

      <ref name="Name" />
      <optional>
        <ref name="USR" />
      </optional>
      <optional>
        <ref name="Headerfile" />
      </optional>
      <optional>
        <ref name="Declaration" />
      </optional>
      <optional>
        <ref name="Abstract" />
      </optional>
      <optional>
        <ref name="TemplateParameters" />
      </optional>
      <optional>
        <ref name="Parameters" />
      </optional>
      <optional>
        <ref name="Exceptions" />
      </optional>
      <zeroOrMore>
        <ref name="Availability" />
      </zeroOrMore>
      <zeroOrMore>
        <ref name="Deprecated" />
      </zeroOrMore>
      <zeroOrMore>
        <ref name="Unavailable" />
      </zeroOrMore>
      <optional>
        <ref name="ResultDiscussion" />
      </optional>
      <optional>
        <ref name="Discussion" />
      </optional>
    </element>
  </define>

  <define name="Class">
    <element name="Class">
      <optional>
        <attribute name="templateKind">
          <choice>
            <value>template</value>
            <value>specialization</value>
            <value>partialSpecialization</value>
          </choice>
        </attribute>
      </optional>
      <ref name="attrSourceLocation" />

      <ref name="Name" />
      <optional>
        <ref name="USR" />
      </optional>
      <optional>
        <ref name="Headerfile" />
      </optional>
      <optional>
        <ref name="Declaration" />
      </optional>
      <optional>
        <ref name="Abstract" />
      </optional>
      <optional>
        <ref name="TemplateParameters" />
      </optional>

      <!-- Parameters and results don't make sense for classes, but the user
           can specify \param or \returns in a comment anyway. -->
      <optional>
        <ref name="Parameters" />
      </optional>
      <optional>
        <ref name="ResultDiscussion" />
      </optional>

      <optional>
        <ref name="Discussion" />
      </optional>
    </element>
  </define>

  <define name="Variable">
    <element name="Variable">
      <ref name="attrSourceLocation" />
      <ref name="Name" />
      <optional>
        <ref name="USR" />
      </optional>
      <optional>
        <ref name="Headerfile" />
      </optional>
      <optional>
        <ref name="Declaration" />
      </optional>
      <optional>
        <ref name="Abstract" />
      </optional>

      <!-- Template parameters, parameters and results don't make sense for
            variables, but the user can specify \tparam \param or \returns
            in a comment anyway. -->
      <optional>
        <ref name="TemplateParameters" />
      </optional>
      <optional>
        <ref name="Parameters" />
      </optional>
      <optional>
        <ref name="ResultDiscussion" />
      </optional>

      <optional>
        <ref name="Discussion" />
      </optional>
    </element>
  </define>

  <define name="Namespace">
    <element name="Namespace">
      <ref name="attrSourceLocation" />
      <ref name="Name" />
      <optional>
        <ref name="USR" />
      </optional>
      <optional>
        <ref name="Headerfile" />
      </optional>
      <optional>
        <ref name="Declaration" />
      </optional>
      <optional>
        <ref name="Abstract" />
      </optional>

      <!-- Template parameters, parameters and results don't make sense for
           namespaces, but the user can specify \tparam, \param or \returns
           in a comment anyway. -->
      <optional>
        <ref name="TemplateParameters" />
      </optional>
      <optional>
        <ref name="Parameters" />
      </optional>
      <optional>
        <ref name="ResultDiscussion" />
      </optional>

      <optional>
        <ref name="Discussion" />
      </optional>
    </element>
  </define>

  <define name="Typedef">
    <element name="Typedef">
      <ref name="attrSourceLocation" />
      <ref name="Name" />
      <optional>
        <ref name="USR" />
      </optional>
      <optional>
        <ref name="Headerfile" />
      </optional>
      <optional>
        <ref name="Declaration" />
      </optional>
      <optional>
        <ref name="Abstract" />
      </optional>

      <optional>
        <ref name="TemplateParameters" />
      </optional>

      <!-- Parameters and results might make sense for typedefs if the type is
           a function pointer type. -->
      <optional>
        <ref name="Parameters" />
      </optional>
      <optional>
        <ref name="ResultDiscussion" />
      </optional>

      <optional>
        <ref name="Discussion" />
      </optional>
    </element>
  </define>

  <define name="Enum">
    <element name="Enum">
      <ref name="attrSourceLocation" />
      <ref name="Name" />
      <optional>
        <ref name="USR" />
      </optional>
      <optional>
        <ref name="Headerfile" />
      </optional>
      <optional>
        <ref name="Declaration" />
      </optional>
      <optional>
        <ref name="Abstract" />
      </optional>

      <!-- Template parameters, parameters and results don't make sense for
            enums, but the user can specify \tparam \param or \returns in a
            comment anyway. -->
      <optional>
        <ref name="TemplateParameters" />
      </optional>
      <optional>
        <ref name="Parameters" />
      </optional>
      <optional>
        <ref name="ResultDiscussion" />
      </optional>

      <optional>
        <ref name="Discussion" />
      </optional>
    </element>
  </define>

  <define name="attrSourceLocation">
    <optional>
      <attribute name="file">
        <!-- Non-empty text content. -->
        <data type="string">
          <param name="pattern">.*\S.*</param>
        </data>
      </attribute>
    </optional>
    <optional>
      <attribute name="line">
        <data type="positiveInteger" />
      </attribute>
      <attribute name="column">
        <data type="positiveInteger" />
      </attribute>
    </optional>
  </define>

  <define name="Name">
    <element name="Name">
      <!-- Non-empty text content. -->
      <data type="string">
        <param name="pattern">.*\S.*</param>
      </data>
    </element>
  </define>

  <define name="USR">
    <element name="USR">
      <!-- Non-empty text content. -->
      <data type="string">
        <param name="pattern">.*\S.*</param>
      </data>
    </element>
  </define>

  <define name="Abstract">
    <element name="Abstract">
      <zeroOrMore>
        <ref name="TextBlockContent" />
      </zeroOrMore>
    </element>
  </define>

  <define name="Declaration">
    <element name="Declaration">
      <!-- Non-empty text content. -->
      <data type="string"/>
    </element>
  </define>

  <define name="Headerfile">
    <element name="Headerfile">
      <oneOrMore>
        <ref name="TextBlockContent" />
      </oneOrMore>
    </element>
  </define>

  <define name="Discussion">
    <element name="Discussion">
      <zeroOrMore>
        <ref name="TextBlockContent" />
      </zeroOrMore>
    </element>
  </define>

  <define name="TemplateParameters">
    <element name="TemplateParameters">
      <!-- Parameter elements should be sorted according to position. -->
      <oneOrMore>
        <element name="Parameter">
          <element name="Name">
            <!-- Non-empty text content. -->
            <data type="string">
              <param name="pattern">.*\S.*</param>
            </data>
          </element>
          <optional>
            <!-- This is index at depth 0.  libclang API can return more
                 information about position, but we expose only essential
                 information here, since "Parameter" elements are already
                 sorted.

                 "Position" element could be added in future if needed.  -->
            <element name="Index">
              <data type="nonNegativeInteger" />
            </element>
          </optional>
          <!-- In general, template parameters with whitespace discussion
               should not be emitted.  Schema might be more strict here. -->
          <element name="Discussion">
            <ref name="TextBlockContent" />
          </element>
        </element>
      </oneOrMore>
    </element>
  </define>

  <define name="Parameters">
    <element name="Parameters">
      <!-- Parameter elements should be sorted according to index. -->
      <oneOrMore>
        <element name="Parameter">
          <element name="Name">
            <!-- Non-empty text content. -->
            <data type="string">
              <param name="pattern">.*\S.*</param>
            </data>
          </element>
          <optional>
            <choice>
              <element name="Index">
                <data type="nonNegativeInteger" />
              </element>
              <element name="IsVarArg">
                <empty />
              </element>
            </choice>
          </optional>
          <element name="Direction">
            <attribute name="isExplicit">
              <data type="boolean" />
            </attribute>
            <choice>
              <value>in</value>
              <value>out</value>
              <value>in,out</value>
            </choice>
          </element>
          <!-- In general, template parameters with whitespace discussion
               should not be emitted, unless direction is explicitly specified.
               Schema might be more strict here. -->
          <element name="Discussion">
            <ref name="TextBlockContent" />
          </element>
        </element>
      </oneOrMore>
    </element>
  </define>

  <define name="Exceptions">
    <element name="Exceptions">
      <oneOrMore>
        <ref name="TextBlockContent" />
      </oneOrMore>
    </element>
  </define>

  <define name="Availability">
    <element name="Availability">
      <attribute name="distribution">
        <data type="string" />
      </attribute>
      <optional>
        <element name="IntroducedInVersion">
          <data type="string">
            <param name="pattern">\d+|\d+\.\d+|\d+\.\d+.\d+</param>
          </data>
        </element>
      </optional>
      <optional>
        <element name="DeprecatedInVersion">
          <data type="string">
            <param name="pattern">\d+|\d+\.\d+|\d+\.\d+.\d+</param>
          </data>
        </element>
      </optional>
      <optional>
        <element name="RemovedAfterVersion">
          <data type="string">
            <param name="pattern">\d+|\d+\.\d+|\d+\.\d+.\d+</param>
          </data>
        </element>
      </optional>
      <optional>
        <element name="DeprecationSummary">
          <data type="string" />
        </element>
      </optional>
      <optional>
        <ref name="Unavailable" />
      </optional>
    </element>
  </define>

  <define name="Deprecated">
    <element name="Deprecated">
      <optional>
        <data type="string" />
      </optional>
    </element>
  </define>

  <define name="Unavailable">
    <element name="Unavailable">
      <optional>
        <data type="string" />
      </optional>
    </element>
  </define>

  <define name="ResultDiscussion">
    <element name="ResultDiscussion">
      <zeroOrMore>
        <ref name="TextBlockContent" />
      </zeroOrMore>
    </element>
  </define>

  <define name="TextBlockContent">
    <choice>
      <element name="Para">
        <optional>
          <attribute name="kind">
            <choice>
              <value>attention</value>
              <value>author</value>
              <value>authors</value>
              <value>bug</value>
              <value>copyright</value>
              <value>date</value>
              <value>invariant</value>
              <value>note</value>
              <value>post</value>
              <value>pre</value>
              <value>remark</value>
              <value>remarks</value>
              <value>sa</value>
              <value>see</value>
              <value>since</value>
              <value>todo</value>
              <value>version</value>
              <value>warning</value>
            </choice>
          </attribute>
        </optional>
        <zeroOrMore>
          <ref name="TextInlineContent" />
        </zeroOrMore>
      </element>
      <element name="Verbatim">
        <attribute name="xml:space">
          <value>preserve</value>
        </attribute>
        <attribute name="kind">
          <!-- TODO: add all Doxygen verbatim kinds -->
          <choice>
            <value>code</value>
            <value>verbatim</value>
          </choice>
        </attribute>
        <text />
      </element>
    </choice>
  </define>

  <define name="TextInlineContent">
    <choice>
      <text />
      <element name="bold">
        <!-- Non-empty text content. -->
        <data type="string">
          <param name="pattern">.*\S.*</param>
        </data>
      </element>
      <element name="monospaced">
        <!-- Non-empty text content. -->
        <data type="string">
          <param name="pattern">.*\S.*</param>
        </data>
      </element>
      <element name="emphasized">
        <!-- Non-empty text content. -->
        <data type="string">
          <param name="pattern">.*\S.*</param>
        </data>
      </element>
      <element name="anchor">
        <attribute name="id">
          <data type="string">
            <!-- Non-empty text content without whitespace. -->
            <param name="pattern">\S+</param>
          </data>
        </attribute>
      </element>
      <element name="rawHTML">
        <optional>
          <!-- If not specified, the default value is 'false'. -->
          <!-- The value 'false' or absence of the attribute does not imply
               that the HTML is actually well-formed. -->
          <attribute name="isMalformed">
            <data type="boolean" />
          </attribute>
        </optional>
        <!-- Non-empty text content. -->
        <data type="string">
          <param name="pattern">.*\S.*</param>
        </data>
      </element>
    </choice>
  </define>

</grammar>