1/*==-- clang-c/Documentation.h - Utilities for comment processing -*- C -*-===*\
3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
8|*===----------------------------------------------------------------------===*|
10|* This header provides a supplementary interface for inspecting *|
11|* documentation comments. *|
13\*===----------------------------------------------------------------------===*/
15#ifndef LLVM_CLANG_C_DOCUMENTATION_H
16#define LLVM_CLANG_C_DOCUMENTATION_H
25 * \defgroup CINDEX_COMMENT Comment introspection
27 * The routines in this group provide access to information in documentation
28 * comments. These facilities are distinct from the core and may be subject to
29 * their own schedule of stability and deprecation.
43 * Given a cursor that represents a documentable entity (e.g.,
44 * declaration), return the associated parsed comment as a
45 * \c CXComment_FullComment AST node.
50 * Describes the type of the comment AST node (\c CXComment). A comment
51 * node can be considered block content (e. g., paragraph), inline content
52 * (plain text) or neither (the root AST node).
56 * Null comment. No AST node is constructed at the requested location
57 * because there is no text or a syntax error.
62 * Plain text. Inline content.
67 * A command with word-like arguments that is considered inline content.
69 * For example: \\c command.
74 * HTML start tag with attributes (name-value pairs). Considered
79 * <br> <br /> <a href="http://example.org/">
85 * HTML end tag. Considered inline content.
95 * A paragraph, contains inline comment. The paragraph itself is
101 * A command that has zero or more word-like arguments (number of
102 * word-like arguments depends on command name) and a paragraph as an
103 * argument. Block command is block content.
105 * Paragraph argument is also a child of the block command.
107 * For example: \has 0 word-like arguments and a paragraph argument.
109 * AST nodes of special kinds that parser knows about (e. g., \\param
110 * command) have their own node kinds.
115 * A \\param or \\arg command that describes the function parameter
116 * (name, passing direction, description).
118 * For example: \\param [in] ParamName description.
123 * A \\tparam command that describes a template parameter (name and
126 * For example: \\tparam T description.
131 * A verbatim block command (e. g., preformatted code). Verbatim
132 * block has an opening and a closing command and contains multiple lines of
133 * text (\c CXComment_VerbatimBlockLine child nodes).
143 * A line of text that is contained within a
144 * CXComment_VerbatimBlockCommand node.
149 * A verbatim line command. Verbatim line has an opening command,
150 * a single line of text (up to the newline after the opening command) and
151 * has no closing command.
156 * A full comment attached to a declaration, contains block content.
162 * The most appropriate rendering mode for an inline command, chosen on
163 * command semantics in Doxygen.
167 * Command argument should be rendered in a normal font.
172 * Command argument should be rendered in a bold font.
177 * Command argument should be rendered in a monospaced font.
182 * Command argument should be rendered emphasized (typically italic
188 * Command argument should not be rendered (since it only defines an anchor).
194 * Describes parameter passing direction for \\param or \\arg command.
198 * The parameter is an input parameter.
203 * The parameter is an output parameter.
208 * The parameter is an input and output parameter.
214 * \param Comment AST node of any kind.
216 * \returns the type of the AST node.
221 * \param Comment AST node of any kind.
223 * \returns number of children of the AST node.
228 * \param Comment AST node of any kind.
230 * \param ChildIdx child index (zero-based).
232 * \returns the specified child of the AST node.
238 * A \c CXComment_Paragraph node is considered whitespace if it contains
239 * only \c CXComment_Text nodes that are empty or whitespace.
241 * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
242 * never considered whitespace.
244 * \returns non-zero if \c Comment is whitespace.
249 * \returns non-zero if \c Comment is inline content and has a newline
250 * immediately following it in the comment text. Newlines between paragraphs
257 * \param Comment a \c CXComment_Text AST node.
259 * \returns text contained in the AST node.
264 * \param Comment a \c CXComment_InlineCommand AST node.
266 * \returns name of the inline command.
272 * \param Comment a \c CXComment_InlineCommand AST node.
274 * \returns the most appropriate rendering mode, chosen on command
275 * semantics in Doxygen.
281 * \param Comment a \c CXComment_InlineCommand AST node.
283 * \returns number of command arguments.
289 * \param Comment a \c CXComment_InlineCommand AST node.
291 * \param ArgIdx argument index (zero-based).
293 * \returns text of the specified argument.
300 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
303 * \returns HTML tag name.
308 * \param Comment a \c CXComment_HTMLStartTag AST node.
310 * \returns non-zero if tag is self-closing (for example, <br />).
316 * \param Comment a \c CXComment_HTMLStartTag AST node.
318 * \returns number of attributes (name-value pairs) attached to the start tag.
323 * \param Comment a \c CXComment_HTMLStartTag AST node.
325 * \param AttrIdx attribute index (zero-based).
327 * \returns name of the specified attribute.
333 * \param Comment a \c CXComment_HTMLStartTag AST node.
335 * \param AttrIdx attribute index (zero-based).
337 * \returns value of the specified attribute.
343 * \param Comment a \c CXComment_BlockCommand AST node.
345 * \returns name of the block command.
351 * \param Comment a \c CXComment_BlockCommand AST node.
353 * \returns number of word-like arguments.
359 * \param Comment a \c CXComment_BlockCommand AST node.
361 * \param ArgIdx argument index (zero-based).
363 * \returns text of the specified word-like argument.
370 * \param Comment a \c CXComment_BlockCommand or
371 * \c CXComment_VerbatimBlockCommand AST node.
373 * \returns paragraph argument of the block command.
379 * \param Comment a \c CXComment_ParamCommand AST node.
381 * \returns parameter name.
387 * \param Comment a \c CXComment_ParamCommand AST node.
389 * \returns non-zero if the parameter that this AST node represents was found
390 * in the function prototype and \c clang_ParamCommandComment_getParamIndex
391 * function will return a meaningful value.
397 * \param Comment a \c CXComment_ParamCommand AST node.
399 * \returns zero-based parameter index in function prototype.
405 * \param Comment a \c CXComment_ParamCommand AST node.
407 * \returns non-zero if parameter passing direction was specified explicitly in
414 * \param Comment a \c CXComment_ParamCommand AST node.
416 * \returns parameter passing direction.
423 * \param Comment a \c CXComment_TParamCommand AST node.
425 * \returns template parameter name.
431 * \param Comment a \c CXComment_TParamCommand AST node.
433 * \returns non-zero if the parameter that this AST node represents was found
434 * in the template parameter list and
435 * \c clang_TParamCommandComment_getDepth and
436 * \c clang_TParamCommandComment_getIndex functions will return a meaningful
443 * \param Comment a \c CXComment_TParamCommand AST node.
445 * \returns zero-based nesting depth of this parameter in the template parameter list.
449 * template<typename C, template<typename T> class TT>
450 * void test(TT<int> aaa);
452 * for C and TT nesting depth is 0,
453 * for T nesting depth is 1.
459 * \param Comment a \c CXComment_TParamCommand AST node.
461 * \returns zero-based parameter index in the template parameter list at a
462 * given nesting depth.
466 * template<typename C, template<typename T> class TT>
467 * void test(TT<int> aaa);
469 * for C and TT nesting depth is 0, so we can ask for index at depth 0:
470 * at depth 0 C's index is 0, TT's index is 1.
472 * For T nesting depth is 1, so we can ask for index at depth 0 and 1:
473 * at depth 0 T's index is 1 (same as TT's),
474 * at depth 1 T's index is 0.
480 * \param Comment a \c CXComment_VerbatimBlockLine AST node.
482 * \returns text contained in the AST node.
488 * \param Comment a \c CXComment_VerbatimLine AST node.
490 * \returns text contained in the AST node.
495 * Convert an HTML tag AST node to string.
497 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
500 * \returns string containing an HTML tag.
505 * Convert a given full parsed comment to an HTML fragment.
507 * Specific details of HTML layout are subject to change. Don't try to parse
508 * this HTML back into an AST, use other APIs instead.
510 * Currently the following CSS classes are used:
511 * \li "para-brief" for \paragraph and equivalent commands;
512 * \li "para-returns" for \\returns paragraph and equivalent commands;
513 * \li "word-returns" for the "Returns" word in \\returns paragraph.
515 * Function argument documentation is rendered as a <dl> list with arguments
516 * sorted in function prototype order. CSS classes used:
517 * \li "param-name-index-NUMBER" for parameter name (<dt>);
518 * \li "param-descr-index-NUMBER" for parameter description (<dd>);
519 * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if
520 * parameter index is invalid.
522 * Template parameter documentation is rendered as a <dl> list with
523 * parameters sorted in template parameter list order. CSS classes used:
524 * \li "tparam-name-index-NUMBER" for parameter name (<dt>);
525 * \li "tparam-descr-index-NUMBER" for parameter description (<dd>);
526 * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for
527 * names inside template template parameters;
528 * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if
529 * parameter position is invalid.
531 * \param Comment a \c CXComment_FullComment AST node.
533 * \returns string containing an HTML fragment.
538 * Convert a given full parsed comment to an XML document.
540 * A Relax NG schema for the XML can be found in comment-xml-schema.rng file
541 * inside clang source tree.
543 * \param Comment a \c CXComment_FullComment AST node.
545 * \returns string containing an XML document.
550 * CXAPISet is an opaque type that represents a data structure containing all
551 * the API information for a given translation unit. This can be used for a
552 * single symbol symbol graph for a given symbol.
557 * Traverses the translation unit to create a \c CXAPISet.
559 * \param tu is the \c CXTranslationUnit to build the \c CXAPISet for.
561 * \param out_api is a pointer to the output of this function. It is needs to be
562 * disposed of by calling clang_disposeAPISet.
564 * \returns Error code indicating success or failure of the APISet creation.
570 * Dispose of an APISet.
572 * The provided \c CXAPISet can not be used after this function is called.
577 * Generate a single symbol symbol graph for the given USR. Returns a null
578 * string if the associated symbol can not be found in the provided \c CXAPISet.
580 * The output contains the symbol graph as well as some additional information
581 * about related symbols.
583 * \param usr is a string containing the USR of the symbol to generate the
586 * \param api the \c CXAPISet to look for the symbol in.
588 * \returns a string containing the serialized symbol graph representation for
589 * the symbol being queried or a null string if it can not be found in the
596 * Generate a single symbol symbol graph for the declaration at the given
597 * cursor. Returns a null string if the AST node for the cursor isn't a
600 * The output contains the symbol graph as well as some additional information
601 * about related symbols.
603 * \param cursor the declaration for which to generate the single symbol symbol
606 * \returns a string containing the serialized symbol graph representation for
607 * the symbol being queried or a null string if it can not be found in the
618#endif /* CLANG_C_DOCUMENTATION_H */
CXErrorCode
Error codes returned by libclang routines.
#define LLVM_CLANG_C_EXTERN_C_END
#define LLVM_CLANG_C_EXTERN_C_BEGIN
struct CXTranslationUnitImpl * CXTranslationUnit
A single translation unit, which resides in an index.
A cursor representing some element in the abstract syntax tree for a translation unit.