1 module clang.c.documentation; 2 import clang.c.CXString; 3 import clang.c.index; 4 5 extern (C) @nogc nothrow @trusted pure: 6 7 /** 8 * \defgroup CINDEX_COMMENT Comment introspection 9 * 10 * The routines in this group provide access to information in documentation 11 * comments. These facilities are distinct from the core and may be subject to 12 * their own schedule of stability and deprecation. 13 * 14 * @{ 15 */ 16 17 /** 18 * A parsed comment. 19 */ 20 struct CXComment 21 { 22 const(void)* ASTNode; 23 24 /** 25 * Given a cursor that represents a documentable entity (e.g., 26 * declaration), return the associated parsed comment as a 27 * \c CXComment_FullComment AST node. 28 */ 29 30 /** 31 * Describes the type of the comment AST node (\c CXComment). A comment 32 * node can be considered block content (e. g., paragraph), inline content 33 * (plain text) or neither (the root AST node). 34 */ 35 36 /** 37 * Null comment. No AST node is constructed at the requested location 38 * because there is no text or a syntax error. 39 */ 40 41 /** 42 * Plain text. Inline content. 43 */ 44 45 /** 46 * A command with word-like arguments that is considered inline content. 47 * 48 * For example: \\c command. 49 */ 50 51 /** 52 * HTML start tag with attributes (name-value pairs). Considered 53 * inline content. 54 * 55 * For example: 56 * \verbatim 57 * <br> <br /> <a href="http://example.org/"> 58 * \endverbatim 59 */ 60 61 /** 62 * HTML end tag. Considered inline content. 63 * 64 * For example: 65 * \verbatim 66 * </a> 67 * \endverbatim 68 */ 69 70 /** 71 * A paragraph, contains inline comment. The paragraph itself is 72 * block content. 73 */ 74 75 /** 76 * A command that has zero or more word-like arguments (number of 77 * word-like arguments depends on command name) and a paragraph as an 78 * argument. Block command is block content. 79 * 80 * Paragraph argument is also a child of the block command. 81 * 82 * For example: \has 0 word-like arguments and a paragraph argument. 83 * 84 * AST nodes of special kinds that parser knows about (e. g., \\param 85 * command) have their own node kinds. 86 */ 87 88 /** 89 * A \\param or \\arg command that describes the function parameter 90 * (name, passing direction, description). 91 * 92 * For example: \\param [in] ParamName description. 93 */ 94 struct CXTranslationUnitImpl; 95 alias CXTranslationUnit = CXTranslationUnitImpl*; 96 CXTranslationUnit TranslationUnit; 97 } 98 99 CXComment clang_Cursor_getParsedComment (CXCursor C); 100 101 enum CXCommentKind 102 { 103 CXComment_Null = 0, 104 CXComment_Text = 1, 105 CXComment_InlineCommand = 2, 106 CXComment_HTMLStartTag = 3, 107 CXComment_HTMLEndTag = 4, 108 CXComment_Paragraph = 5, 109 CXComment_BlockCommand = 6, 110 CXComment_ParamCommand = 7, 111 112 /** 113 * A \\tparam command that describes a template parameter (name and 114 * description). 115 * 116 * For example: \\tparam T description. 117 */ 118 CXComment_TParamCommand = 8, 119 120 /** 121 * A verbatim block command (e. g., preformatted code). Verbatim 122 * block has an opening and a closing command and contains multiple lines of 123 * text (\c CXComment_VerbatimBlockLine child nodes). 124 * 125 * For example: 126 * \\verbatim 127 * aaa 128 * \\endverbatim 129 */ 130 CXComment_VerbatimBlockCommand = 9, 131 132 /** 133 * A line of text that is contained within a 134 * CXComment_VerbatimBlockCommand node. 135 */ 136 CXComment_VerbatimBlockLine = 10, 137 138 /** 139 * A verbatim line command. Verbatim line has an opening command, 140 * a single line of text (up to the newline after the opening command) and 141 * has no closing command. 142 */ 143 CXComment_VerbatimLine = 11, 144 145 /** 146 * A full comment attached to a declaration, contains block content. 147 */ 148 CXComment_FullComment = 12 149 } 150 151 alias CXComment_Null = CXCommentKind.CXComment_Null; 152 alias CXComment_Text = CXCommentKind.CXComment_Text; 153 alias CXComment_InlineCommand = CXCommentKind.CXComment_InlineCommand; 154 alias CXComment_HTMLStartTag = CXCommentKind.CXComment_HTMLStartTag; 155 alias CXComment_HTMLEndTag = CXCommentKind.CXComment_HTMLEndTag; 156 alias CXComment_Paragraph = CXCommentKind.CXComment_Paragraph; 157 alias CXComment_BlockCommand = CXCommentKind.CXComment_BlockCommand; 158 alias CXComment_ParamCommand = CXCommentKind.CXComment_ParamCommand; 159 alias CXComment_TParamCommand = CXCommentKind.CXComment_TParamCommand; 160 alias CXComment_VerbatimBlockCommand = CXCommentKind.CXComment_VerbatimBlockCommand; 161 alias CXComment_VerbatimBlockLine = CXCommentKind.CXComment_VerbatimBlockLine; 162 alias CXComment_VerbatimLine = CXCommentKind.CXComment_VerbatimLine; 163 alias CXComment_FullComment = CXCommentKind.CXComment_FullComment; 164 165 /** 166 * The most appropriate rendering mode for an inline command, chosen on 167 * command semantics in Doxygen. 168 */ 169 enum CXCommentInlineCommandRenderKind 170 { 171 /** 172 * Command argument should be rendered in a normal font. 173 */ 174 CXCommentInlineCommandRenderKind_Normal = 0, 175 176 /** 177 * Command argument should be rendered in a bold font. 178 */ 179 CXCommentInlineCommandRenderKind_Bold = 1, 180 181 /** 182 * Command argument should be rendered in a monospaced font. 183 */ 184 CXCommentInlineCommandRenderKind_Monospaced = 2, 185 186 /** 187 * Command argument should be rendered emphasized (typically italic 188 * font). 189 */ 190 CXCommentInlineCommandRenderKind_Emphasized = 3, 191 192 /** 193 * Command argument should not be rendered (since it only defines an anchor). 194 */ 195 CXCommentInlineCommandRenderKind_Anchor = 4 196 } 197 198 alias CXCommentInlineCommandRenderKind_Normal = CXCommentInlineCommandRenderKind.CXCommentInlineCommandRenderKind_Normal; 199 alias CXCommentInlineCommandRenderKind_Bold = CXCommentInlineCommandRenderKind.CXCommentInlineCommandRenderKind_Bold; 200 alias CXCommentInlineCommandRenderKind_Monospaced = CXCommentInlineCommandRenderKind.CXCommentInlineCommandRenderKind_Monospaced; 201 alias CXCommentInlineCommandRenderKind_Emphasized = CXCommentInlineCommandRenderKind.CXCommentInlineCommandRenderKind_Emphasized; 202 alias CXCommentInlineCommandRenderKind_Anchor = CXCommentInlineCommandRenderKind.CXCommentInlineCommandRenderKind_Anchor; 203 204 /** 205 * Describes parameter passing direction for \\param or \\arg command. 206 */ 207 enum CXCommentParamPassDirection 208 { 209 /** 210 * The parameter is an input parameter. 211 */ 212 CXCommentParamPassDirection_In = 0, 213 214 /** 215 * The parameter is an output parameter. 216 */ 217 CXCommentParamPassDirection_Out = 1, 218 219 /** 220 * The parameter is an input and output parameter. 221 */ 222 CXCommentParamPassDirection_InOut = 2 223 } 224 225 alias CXCommentParamPassDirection_In = CXCommentParamPassDirection.CXCommentParamPassDirection_In; 226 alias CXCommentParamPassDirection_Out = CXCommentParamPassDirection.CXCommentParamPassDirection_Out; 227 alias CXCommentParamPassDirection_InOut = CXCommentParamPassDirection.CXCommentParamPassDirection_InOut; 228 229 /** 230 * \param Comment AST node of any kind. 231 * 232 * \returns the type of the AST node. 233 */ 234 CXCommentKind clang_Comment_getKind (CXComment Comment); 235 236 /** 237 * \param Comment AST node of any kind. 238 * 239 * \returns number of children of the AST node. 240 */ 241 uint clang_Comment_getNumChildren (CXComment Comment); 242 243 /** 244 * \param Comment AST node of any kind. 245 * 246 * \param ChildIdx child index (zero-based). 247 * 248 * \returns the specified child of the AST node. 249 */ 250 CXComment clang_Comment_getChild (CXComment Comment, uint ChildIdx); 251 252 /** 253 * A \c CXComment_Paragraph node is considered whitespace if it contains 254 * only \c CXComment_Text nodes that are empty or whitespace. 255 * 256 * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are 257 * never considered whitespace. 258 * 259 * \returns non-zero if \c Comment is whitespace. 260 */ 261 uint clang_Comment_isWhitespace (CXComment Comment); 262 263 /** 264 * \returns non-zero if \c Comment is inline content and has a newline 265 * immediately following it in the comment text. Newlines between paragraphs 266 * do not count. 267 */ 268 uint clang_InlineContentComment_hasTrailingNewline (CXComment Comment); 269 270 /** 271 * \param Comment a \c CXComment_Text AST node. 272 * 273 * \returns text contained in the AST node. 274 */ 275 CXString clang_TextComment_getText (CXComment Comment); 276 277 /** 278 * \param Comment a \c CXComment_InlineCommand AST node. 279 * 280 * \returns name of the inline command. 281 */ 282 CXString clang_InlineCommandComment_getCommandName (CXComment Comment); 283 284 /** 285 * \param Comment a \c CXComment_InlineCommand AST node. 286 * 287 * \returns the most appropriate rendering mode, chosen on command 288 * semantics in Doxygen. 289 */ 290 CXCommentInlineCommandRenderKind clang_InlineCommandComment_getRenderKind ( 291 CXComment Comment); 292 293 /** 294 * \param Comment a \c CXComment_InlineCommand AST node. 295 * 296 * \returns number of command arguments. 297 */ 298 uint clang_InlineCommandComment_getNumArgs (CXComment Comment); 299 300 /** 301 * \param Comment a \c CXComment_InlineCommand AST node. 302 * 303 * \param ArgIdx argument index (zero-based). 304 * 305 * \returns text of the specified argument. 306 */ 307 CXString clang_InlineCommandComment_getArgText (CXComment Comment, uint ArgIdx); 308 309 /** 310 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST 311 * node. 312 * 313 * \returns HTML tag name. 314 */ 315 CXString clang_HTMLTagComment_getTagName (CXComment Comment); 316 317 /** 318 * \param Comment a \c CXComment_HTMLStartTag AST node. 319 * 320 * \returns non-zero if tag is self-closing (for example, <br />). 321 */ 322 uint clang_HTMLStartTagComment_isSelfClosing (CXComment Comment); 323 324 /** 325 * \param Comment a \c CXComment_HTMLStartTag AST node. 326 * 327 * \returns number of attributes (name-value pairs) attached to the start tag. 328 */ 329 uint clang_HTMLStartTag_getNumAttrs (CXComment Comment); 330 331 /** 332 * \param Comment a \c CXComment_HTMLStartTag AST node. 333 * 334 * \param AttrIdx attribute index (zero-based). 335 * 336 * \returns name of the specified attribute. 337 */ 338 CXString clang_HTMLStartTag_getAttrName (CXComment Comment, uint AttrIdx); 339 340 /** 341 * \param Comment a \c CXComment_HTMLStartTag AST node. 342 * 343 * \param AttrIdx attribute index (zero-based). 344 * 345 * \returns value of the specified attribute. 346 */ 347 CXString clang_HTMLStartTag_getAttrValue (CXComment Comment, uint AttrIdx); 348 349 /** 350 * \param Comment a \c CXComment_BlockCommand AST node. 351 * 352 * \returns name of the block command. 353 */ 354 CXString clang_BlockCommandComment_getCommandName (CXComment Comment); 355 356 /** 357 * \param Comment a \c CXComment_BlockCommand AST node. 358 * 359 * \returns number of word-like arguments. 360 */ 361 uint clang_BlockCommandComment_getNumArgs (CXComment Comment); 362 363 /** 364 * \param Comment a \c CXComment_BlockCommand AST node. 365 * 366 * \param ArgIdx argument index (zero-based). 367 * 368 * \returns text of the specified word-like argument. 369 */ 370 CXString clang_BlockCommandComment_getArgText (CXComment Comment, uint ArgIdx); 371 372 /** 373 * \param Comment a \c CXComment_BlockCommand or 374 * \c CXComment_VerbatimBlockCommand AST node. 375 * 376 * \returns paragraph argument of the block command. 377 */ 378 CXComment clang_BlockCommandComment_getParagraph (CXComment Comment); 379 380 /** 381 * \param Comment a \c CXComment_ParamCommand AST node. 382 * 383 * \returns parameter name. 384 */ 385 CXString clang_ParamCommandComment_getParamName (CXComment Comment); 386 387 /** 388 * \param Comment a \c CXComment_ParamCommand AST node. 389 * 390 * \returns non-zero if the parameter that this AST node represents was found 391 * in the function prototype and \c clang_ParamCommandComment_getParamIndex 392 * function will return a meaningful value. 393 */ 394 uint clang_ParamCommandComment_isParamIndexValid (CXComment Comment); 395 396 /** 397 * \param Comment a \c CXComment_ParamCommand AST node. 398 * 399 * \returns zero-based parameter index in function prototype. 400 */ 401 uint clang_ParamCommandComment_getParamIndex (CXComment Comment); 402 403 /** 404 * \param Comment a \c CXComment_ParamCommand AST node. 405 * 406 * \returns non-zero if parameter passing direction was specified explicitly in 407 * the comment. 408 */ 409 uint clang_ParamCommandComment_isDirectionExplicit (CXComment Comment); 410 411 /** 412 * \param Comment a \c CXComment_ParamCommand AST node. 413 * 414 * \returns parameter passing direction. 415 */ 416 CXCommentParamPassDirection clang_ParamCommandComment_getDirection ( 417 CXComment Comment); 418 419 /** 420 * \param Comment a \c CXComment_TParamCommand AST node. 421 * 422 * \returns template parameter name. 423 */ 424 CXString clang_TParamCommandComment_getParamName (CXComment Comment); 425 426 /** 427 * \param Comment a \c CXComment_TParamCommand AST node. 428 * 429 * \returns non-zero if the parameter that this AST node represents was found 430 * in the template parameter list and 431 * \c clang_TParamCommandComment_getDepth and 432 * \c clang_TParamCommandComment_getIndex functions will return a meaningful 433 * value. 434 */ 435 uint clang_TParamCommandComment_isParamPositionValid (CXComment Comment); 436 437 /** 438 * \param Comment a \c CXComment_TParamCommand AST node. 439 * 440 * \returns zero-based nesting depth of this parameter in the template parameter list. 441 * 442 * For example, 443 * \verbatim 444 * template<typename C, template<typename T> class TT> 445 * void test(TT<int> aaa); 446 * \endverbatim 447 * for C and TT nesting depth is 0, 448 * for T nesting depth is 1. 449 */ 450 uint clang_TParamCommandComment_getDepth (CXComment Comment); 451 452 /** 453 * \param Comment a \c CXComment_TParamCommand AST node. 454 * 455 * \returns zero-based parameter index in the template parameter list at a 456 * given nesting depth. 457 * 458 * For example, 459 * \verbatim 460 * template<typename C, template<typename T> class TT> 461 * void test(TT<int> aaa); 462 * \endverbatim 463 * for C and TT nesting depth is 0, so we can ask for index at depth 0: 464 * at depth 0 C's index is 0, TT's index is 1. 465 * 466 * For T nesting depth is 1, so we can ask for index at depth 0 and 1: 467 * at depth 0 T's index is 1 (same as TT's), 468 * at depth 1 T's index is 0. 469 */ 470 uint clang_TParamCommandComment_getIndex (CXComment Comment, uint Depth); 471 472 /** 473 * \param Comment a \c CXComment_VerbatimBlockLine AST node. 474 * 475 * \returns text contained in the AST node. 476 */ 477 CXString clang_VerbatimBlockLineComment_getText (CXComment Comment); 478 479 /** 480 * \param Comment a \c CXComment_VerbatimLine AST node. 481 * 482 * \returns text contained in the AST node. 483 */ 484 CXString clang_VerbatimLineComment_getText (CXComment Comment); 485 486 /** 487 * Convert an HTML tag AST node to string. 488 * 489 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST 490 * node. 491 * 492 * \returns string containing an HTML tag. 493 */ 494 CXString clang_HTMLTagComment_getAsString (CXComment Comment); 495 496 /** 497 * Convert a given full parsed comment to an HTML fragment. 498 * 499 * Specific details of HTML layout are subject to change. Don't try to parse 500 * this HTML back into an AST, use other APIs instead. 501 * 502 * Currently the following CSS classes are used: 503 * \li "para-brief" for \paragraph and equivalent commands; 504 * \li "para-returns" for \\returns paragraph and equivalent commands; 505 * \li "word-returns" for the "Returns" word in \\returns paragraph. 506 * 507 * Function argument documentation is rendered as a \<dl\> list with arguments 508 * sorted in function prototype order. CSS classes used: 509 * \li "param-name-index-NUMBER" for parameter name (\<dt\>); 510 * \li "param-descr-index-NUMBER" for parameter description (\<dd\>); 511 * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if 512 * parameter index is invalid. 513 * 514 * Template parameter documentation is rendered as a \<dl\> list with 515 * parameters sorted in template parameter list order. CSS classes used: 516 * \li "tparam-name-index-NUMBER" for parameter name (\<dt\>); 517 * \li "tparam-descr-index-NUMBER" for parameter description (\<dd\>); 518 * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for 519 * names inside template template parameters; 520 * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if 521 * parameter position is invalid. 522 * 523 * \param Comment a \c CXComment_FullComment AST node. 524 * 525 * \returns string containing an HTML fragment. 526 */ 527 CXString clang_FullComment_getAsHTML (CXComment Comment); 528 529 /** 530 * Convert a given full parsed comment to an XML document. 531 * 532 * A Relax NG schema for the XML can be found in comment-xml-schema.rng file 533 * inside clang source tree. 534 * 535 * \param Comment a \c CXComment_FullComment AST node. 536 * 537 * \returns string containing an XML document. 538 */ 539 CXString clang_FullComment_getAsXML (CXComment Comment); 540 541 /** 542 * @} 543 */ 544 545 /* CLANG_C_DOCUMENTATION_H */