summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodemarker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QDoc: Move QDoc source files under a further "qdoc" directoryLuca Di Sera2023-04-121-593/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDoc development under the "qttools" repository is currently performed under the "src/qdoc" directory, which contains all source files and directories relevant to QDoc as direct children. Due to a slow restructuring of how QDoc works, what its dependencies are and certain possible architectural changes, the infrastructure that is expected to be required for the development of QDoc might increase. Some of that infrastructure, which might require some custom effort, is expected to be developed as "independent" "library-like" sub-projects, which QDoc depends on. Albeit developed "independently", such infrastructure would be developed specifically for QDoc and thus should live "adjacent" to it. To allow such a structure a new "qdoc" directory was added under the "src/qdoc" directory. All source files and directory that were previously children of the "src/qdoc" directory were moved under the new "qdoc" directory. This preserves the space for QDoc-related elements and the relative project structure while allowing some space for "adjacent" projects that are intended for QDoc specifically. To support the change, a new "CMakeLists.txt" file was introduced under "src/qdoc", which dispatches to the "CMakeLists.txt" file in the new "src/qdoc/qdoc" directory. QDoc is only built when certain dependencies are found. This is supported through the use of Qt features at the CMake level. The "CMakeLists.txt" file in "src", thus dispatched to the "src/qdoc" directory only when the required features were found. As "independent", "library-like", entities might not have the same requirements as QDoc, the "CMakeLists.txt" file in "src" was modified to always dispatch to the "src/qdoc" directory while the features-check was moved to the new "CMakeLists.txt" files in "src/qdoc", so as to allow non-QDoc but QDoc-specific project to have an independent configuration for building. Certain test projects in "test/auto/qdoc/" depends on QDoc-specific source-files to generate their CMake targets. Those dependencies were generally specified as relative paths. The additional level in the directory structure invalidated the paths and, hence, the relevant "CMakeLists.txt" files for those projects were modified to correctly refer to the new directory structure. Change-Id: I50c7106614428753544eaba5091e1e44d48fd31d Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: C++ marker: Allow single quote as a separator in integer literalsTopi Reinio2023-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | Since C++14, single quotes can appear in integer literals as separators to improve readability. When quoting a file that contains such a literal, QDoc interpreted the single quote as a delimiter for a char, and kept reading ahead for the closing quote. This interfered with correct marking up of C++ code and ultimately caused a warning: (qdoc) warning: Something is wrong with qdoc's handling of marked code as the plain code and marked-up code end up having different number of lines. Pick-to: 6.5 Fixes: QTBUG-111973 Change-Id: Icd2d95973f9cee72eb1c9e3f2d79df0af643dbaa Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Fix clang warnings about temporary QRegularExpression objectsFriedemann Kleint2022-12-021-3/+3
| | | | | | | Pick-to: 6.4 Change-Id: I0d6c597552103251a8c09418d83ea2e38ed10012 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Luca Di Sera <luca.disera@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: I95f6410e57a6a92b1cf91bbedfbe3d517cab6b44 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QDoc: Remove unfinished support for documenting javascriptLuca Di Sera2022-09-071-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The codebase for QDoc has support for commands related to documenting pure javascript codebases. Generally, given a certain QML specific command, a javascript equivalent is provided. For example, "\jstype" or "\jsmodule". Codewise, the support is bolted on by reusing the exact same code that is used for QML types. The internal structures used to represent QML elements, like `QmlPropertyNode`, were reused for javascript elements, with the sole difference of changing the metaness value, for elements where the metaness is meaningful, and the internal type tag of the node. Code that branched specifically with QML types was modified to branch for javascript types too, with mostly no other difference in the branched code itself. The support for javascript was never finalized, albeit it is supposed to work, lacking, for example, representation in the documentation. As a consequence of this it is not currently used, tested or necessary. Hence, the code supporting the documentation of javascript elements is now removed as dead code. Anything referring to javascript specific elements were removed, from the commands definitions to the categorization functions. "Node::changeType" and "FunctionNode::changeMetaness", that switched the type and metaness, respectively, of an existing node with a new one, albeit implemented in a more general fashion, are now removed as dead code, since they were used specifically to "convert" Qml nodes to "javascript nodes". References to javascript were removed in the documentation for QDoc. Do note that not all javascript related features were removed from the codebase. In particular, the "js" and "endjs" commands, to mark a codeblock as being javascript code, and their supporting code such as `JsCodeMarker`, were currently retained as, albeit no documentation exists, are currently used a couple of time in the current Qt's codebase. The remaining javascript specific code is expected to be addressed and removed in a future commit, unless the current usages are specific enough that they cannot be replaced with qml specific commands. Task-number: QTBUG-106275 Change-Id: I6a199ce97b26d6a3a645c0022e599a8654989a85 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Assume that aggregates have a single meaningful include fileLuca Di Sera2022-07-081-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDoc's `Aggregates`, which are used to internally represent "containing" elements, such as cpp classes, have a concept of "include files". "include files" represent the name of a file or similar construct from which the aggregate can be obtained the sources. For example, the name an header file declaring a cpp class. Aggregates, up to now, exposed an interface that allowed to set multiple "include file" for each aggregate. Furthermore, QDoc allows the user to manually specify include files through the use of the "\inheaderfile" command. Those include files were later used by QDoc to show information about the aggregate, In particular, the generator would show an "include requisite" to help a user understand where to import the aggregate from. The multiplicity of the include files had effects on later parts of the code that either set or read them. For example, the generators whose code required handling the multiplicity to show the required information on multiple lines. In practice, this never took effect as, at least in Qt's codebase, no aggregate has more than 1 include file. While it is not unthinkable of wanting to have more than one include file, we consider improbable for it to happen. In general, include file will mostly be used for classes, which we expect to be able to be meaningfully included from a specific file only. As such, the interface for `Aggregates` is now modified to expose a single include file per aggregate. The previous methods were removed and a singular version of them was introduced. The internal state of `Aggregate` was modified to take this into account storing a single optional include file instead of a vector of them. A singular include file was set during the construction of `HeaderNode`. The constructor is now modified to use the new interface. Include files are then generally set only during the code parsing phase. In particular, each file-name coming from an "\inheaderfile" command was appended to the vector of include files. Furthermore, each aggregate either inherited the include files of one of its parent or generated one from the aggregate's name when no sensible parent was available, unless a previous "\inheaderfile" command for the aggregate was encountered. The code is now changed to take into account the lack of multiplicity. The semantic is mostly preserved from the previous version and, in the case of the Qt's codebase, is preserved entirely due to no aggregate with more than one include file ever being produced. Some slight semantic breakages are, albeit, included with this change. Previously, if the user provided more than one "\inheaderfile" command, the arguments from all of them would be preserved and saved in the relevant aggregate. With the current change, each "\inheaderfile" after the first will overwrite the preceding value, such that only the last encountered command will be taken, effectively, into account. This breakage would currently be opaque for the user. It is later advised to better expose this behavior through changes to `DocParser`, albeit those changes are not expected to be performed right away as a more thorough inspection of `DocParser` must be made in general. Furthermore, the previous version would set include files that could be the empty string, specifically as they came from an "\inheaderfile" command. The new version ignore empty include files, such that it is ensured that, if an include file was ever provided, that include file is not an empty string. This breakage improves on the previous version, where later user of the include files had to perform possibly costly filtering operations to avoid empty strings, who are expected to have no meaning as an include file. To better support this change and partially help in exposing this semantic, the new interface for the include file exposes an std::optional and informally guarantees, but does not enforce, that if a value is ever set it is not the empty string. The changes to the code were made so as to ensure that this will be the case as for the current codebase. A more thorough enforcement was avoided as it would require deeper changes that are currently unfeasible. User of the include file, namely the generators, were modified to take into account the lack of multiplicity. The generators previously depended on `CodeMarker::markedUpIncludes` to flatten the vector of include files into a representable string. `CodeMarker::markedUpIncludes` is now supplanted with `CodeMarker::markedUpInclude`, its singular version, to take into account the lack of multiplicity. The semantics of the method is preserved and is expected to be equivalent to a call to `CodeMarker::markedUpIncludes` for vectors of include files with a single element, with the exclusion of a trailing newline. Small clean up changes were made to `HtmlGenerator::addIncludeFilesToMap`, which is the main consumer of include file for the HTML format. The method was renamed to its singular version. Some now unnecessary operations, such as the filtering of include files that were the empty string, are now removed. The `text` parameter of the method, previously a `Text*`, is now modified to a reference. The `Text` that is passed to the method is always created in its immediate scope and is never a nullptr, allowing us to remove and unnecessary check. Indeed, calling the method with a nullptr would generally be a no-op, such that there would be no meaning to it in the first place (and there was no flow-requirement for it to be a no-op). A slight change to the laying out of the table in `HtmlGenerator::generateTheTable` was included to better divide the lines of the table. The regression files for `tst_generatedOutput` were regenerated to take into account the additional newlines in the tables. Change-Id: Idebca8a74444328cd21c83be9e3f3b1706907f84 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-191-27/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: I5335388c0472b0ee554234fc7eca60769e504660 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QDoc: Contextualize QML methods/properties in sincelistsLuca Di Sera2022-05-181-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | QDoc allows the construction of a summary page based on user-provided `\since` information through the `\sincelist` command, to present an overview of the changes occurring between versions of the software. The list presents, among other, newly introduced QML methods and properties, but does so in a flat-way where the methods/properties not contextualized to the QML types holding them. To provide a more easily digestible and useful list of the new QML features, the presentation of QML methods and properties was modified follow the same presentation, for consistency, that CPP's member functions follow, showing each new element under a reference to the holding parent. Furthermore, the presentation of QML properties was modified to include information about the type of the property itself, which was previously missing. Fixes: QTBUG-102088 Pick-to: 6.3 6.2 Change-Id: I7007614e8db21164e9525c160c6ea124218c5bb3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Remove quotefunction from the codebaseLuca Di Sera2022-01-281-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The codebase for QDoc implements a command, 'quotefunction', that eases quoting a specifying function from a currently being-quoted file. The command is unused in Qt's documentation, is undocumented in the QDoc manual and only appears as a string (but not a call to the command itself), inside of the files used by `tst_generatedOutput`. While, arguably, there might be some use to higher-level commands that simplify common operations that might be done trough the use of the `quotefromfile` family of commands, `quotefunction` itself is, currently, no more than dead code, and is thus removed, knowing that it can be reintroduced with ease should the need arise, as a mean to simplify the upcoming changes to the quoting system. `DocParser::slashed` is now removed as it was used only during the processing of a 'quotefunction' command. The machinery which supported this feature in the `CodeMarker` family of classes, `functionBeginRegExp` and `functionEndRegExp`, was removed as it is now unused. The `quotefunction` string in the input data to `tst_generatedOutput` was removed and the output was regenerated to take the change into account. Change-Id: Ied2b04e0f3f1a74ff60300e83e2a514de872b7cb Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Simplify static initialization in CppCodeMarker::addMarkUpLuca Di Sera2022-01-281-55/+39
| | | | | | | | | | | | | | | | | | | | `CppCodeMarker::addMarkUp` uses two static collections to define what is considered a keyword or a primitive type when lexing code. The initialization was done manually, hidden behind a branch to ensure that it was executed only once, by copying the values from some statically initialized arrays. Supposedly, this was necessary at the time the code was written for a lack of a suitable constructor for a `QSet`. As static values are already initialized only once and the manual initialization mirrors what `QSet`'s `inizializer_list` constructor does, the code was modified to remove the branching and initialize the collections in place. Change-Id: Ic2ca86054970bd257ca7cbaba12c17de2bc177d3 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Improve \deprecated commandPaul Wicking2021-05-101-4/+6
| | | | | | | | | | | | | | | | | | | | | | This change allows users to specify an optional parameter to the \deprecated command to record which version something was deprecated. It also allows for free text descriptions. These descriptions become the first paragraph of the resulting documentation. Usage: \deprecated \deprecated [6.2] \deprecated [6.2] Use QFoo() instead. \deprecated Use QFoo() instead. [ChangeLog][qdoc] QDoc now lets you record the version something is deprecated and suggest replacements with the \deprecated command. Task-number: QTBUG-58249 Change-Id: I27081627132b2f8ea3dd7d48ded8e37213366074 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Remove Node::Obsolete statusTopi Reinio2021-05-101-1/+1
| | | | | | | | | | | | | | | | | QDoc had two commands for the same purpose, \obsolete and \deprecated. As 'deprecated' describes the status better, as in, something that is subject to being removed from the public API, document only the latter. Keep \obsolete for now for backward compatibility. .index file recognize the "obsolete" attribute still for backward compatibility, converting to "deprecated". [ChangeLog][qdoc] Replaced \obsolete command in favor of \deprecated as it's a more accurate description of the intended status. Task-number: QTBUG-58249 Change-Id: I3d311ebf7b4a3e8a23fa85e4efcf60965cf12a13 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QDoc: Code cleanupPaul Wicking2021-05-031-25/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use multiple arguments for QStrings instead of calling .arg() multiple times. * Define trivial constructor/destructor '= default' instead of adding empty implementations. * Remove unreachable code. * Prefer ranged-based for loops. * Initialize with auto from static_cast<>() and new. * Simplify expressions. * Prefer "QList::empty()" over "QList::size() > 0". * Remove unused method. * Return qsizetype instead of int to avoid narrowing conversion. * Remove unused include. * Remove unreachable return statement. * Prefer raw string literals over escaped regexes. * Initialize struct members. * Make variables used as const refs const refs. * Use std::move instead of passing const ref in ctor. * Drop redundant 'virtual' from methods marked 'override'. * Make local copies that arent ever modified const refs to avoid copying. * Turn for-loop into std::any_of. * Made single-argument constructor explicit. * Don't shadow variable names from outer scope if not necessary. * Remove const at top level that does not improve const correctness. * Update copyright notice for affected classes. Task-number: QTBUG-71176 Change-Id: Ia41e5b947b72f594b60d189b6b0ff68587c3afb9 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Revert "QDoc: Add \deprecatedsince command"Paul Wicking2021-04-301-6/+3
| | | | | | | | | | | | This reverts commit 1637d91efd8fb389bc09bdaa960f5d9d4f9e0164. Reason for revert: User feedback shows this implementation isn't good enough. Further discussion led to the discovery of a better approach. Task-number: QTBUG-58249 Change-Id: I48e0500ac95745b1ce10a29e77c6fa515b9e048f Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QDoc: Add \deprecatedsince commandPaul Wicking2021-04-281-3/+6
| | | | | | | | | | | | | As deprecated methods may stick around over a couple of versions, add a command that lets us record which version something was deprecated in. [ChangeLog][qdoc] QDoc now lets you record the version something is deprecated in with the new \deprecatedsince command. Fixes: QTBUG-58249 Change-Id: I69de350502580f446008f717462bbc1c4c251564 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Fix incorrect usage of QChar(EOF)Topi Reinio2020-11-231-13/+18
| | | | | | | | | | | | | Since qtbase commit 915be660, QChar(EOF), where EOF is defined as (-1) in stdlib.h, is deemed incorrect and causes an assert. Instead of assigning EOF to QChar, replace the readChar() macro with a lambda and track the EOF state with a boolean. Pick-to: 6.0 Fixes: QTBUG-88687 Change-Id: I480054cd36dc049909f709e23269d42deffecec1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qttools: compile with explicit QChar(int)David Faure2020-11-111-1/+1
| | | | | | | | | | Notice how this caught a bad bug: the code was generating "listitem\001" instead of "listitem1" It seems no unittest covers this, they all pass, still. Change-Id: Ibb22231c9dc3e61d3ea0a84894e451c621d50121 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qdoc: Unify generated documentation between \typedef and \typealiasTopi Reinio2020-11-091-11/+5
| | | | | | | | | | | | | | | | | | | | | | | | \typedef can be used as a substitute for \typealias for documenting aliases. Since they are identical in terms of usage, unify also the way they are documented: - Remove 'typedef' and '(alias)' from both the summary and details sections, making both appear as types. - Remove automatically generated 'This is a type alias for ...' note for type aliases. This typically resulted in duplicate statements. - Use '-typedef' anchor suffix for both. - Use 'typedef' as element for both in .index files and webxml output format. - Add template parameters for type aliases for DocBook generator; these were previously missing. Fixes: QTBUG-87622 Change-Id: I93986a2dc91c3c3dff9e21f5bf5cf19d0b55c4df Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Fix handling of \fn signatures with unnamed parametersTopi Reinio2020-10-271-9/+4
| | | | | | | | | | | | | | | | A misplaced 'i++' caused an error where names of documented parameters were shifted around if one or more of the parameters were unnamed. Fixing the above uncovered issues with handling of \fn commands with [tag] argument; improve and simplify related code. Finally, avoid redundant space characters when generating signatures with unnamed parameters or in 'All Members' page where parameter names are omitted. Fixes: QTBUG-87855 Change-Id: I526c89c10c66572b8c71106660f43346a4751e4e Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Port QtTools from QStringRef to QStringViewKarsten Heimrich2020-06-151-3/+3
| | | | | | Task-number: QTBUG-84319 Change-Id: Idb5a41172ea38b2f4edf385d67c1cdc2968a8d8c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qdoc: Extend synopsis for detailed reference sectionsTopi Reinio2020-06-081-35/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Include \since information for detailed synopsis generation, and allow duplication of qdoc comments for C++/QML nodes on the condition that the extra comments contain no body text, only meta-commands. The use case is to have full status information in the signature/section title, and allow additional meta-commands for items that share a documentation comment. /*! \fn void A:foo() \fn void A:foo(int i) Shared documentation for overloads. */ /*! \fn void A:foo(int i) \since 2.0 */ Extract the code for 'extra' synopsis into a new helper function and use for both HTML and DocBook generators. Fixes: QTBUG-55739 Fixes: QTBUG-82902 Change-Id: I6e797d3ce7bc7b02102bb949515f88e7a0fbe929 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract NamespaceNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: Ic5e0adbbeb27266ba1a55132a54310021f98fc21 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract enum Access from NodePaul Wicking2020-06-041-2/+3
| | | | | | | | | | | | | Move Node::Access out of Node and make it a scoped enum, to break circular dependency issues between Node and RelatedClass. This is a requirement to extract struct RelatedClass from Node. Task-number: QTBUG-84578 Change-Id: I13a1ac275d46abcd04f5f712291c77c2f24a65db Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract QmlPropertyNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: If9a8eed6a01c6c7682a47572a16213f0d174087e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract EnumNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: I06f0f91677adc5f0673b1eba414b131def101601 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract TypedefNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: I8fbe13faefd918b616f8d0d4bc08077a880b6194 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract FunctionNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: I5967054a1c802ac6daf2622dcd4e4c8c4b3977ac Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract PropertyNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: I88b684150e797a92e943f064019a418d640065a7 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Extract VariableNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: I978797538095b2b82000aff0c16242fa7628c0ac Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Improve handling of templated typesTopi Reinio2020-06-041-4/+9
| | | | | | | | | | | | | | | | | | | | The Clang visitor did not differentiate between templated class-like types, always assuming that it is a 'class'. Fix this by retrieving the type of the specialization the template refers to. Ensure that templated structs and unions are named correctly in the generated output. Handle the type of the cursor that refers to a templated type alias, and improve the code for resolving the template parameters for aliases. [ChangeLog][qdoc] QDoc now correctly handles templated structs, unions, and type aliases. Pick-to: 5.15 Fixes: QTBUG-67432 Change-Id: Ia0fbfe7b7f22a54270650d96d0d67a4b8b8fd182 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devTopi Reinio2020-05-291-0/+7
|\ | | | | | | Change-Id: I8c1fc05462e1b99b16d52e4f43b2b4b1aa645152
| * qdoc: properly implement \typealias commandTopi Reinio2020-04-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | \typealias was already a command recognized by QDoc, but it was simply treated as a synonym for \typedef and was not documented. Implement proper support for the command: - Add [alias] designation both in type summary and details. - Auto-generate information about the aliased type, including a link if aliasing a public, documented type. - Auto-convert aliases documented with \typedef to type aliases. - Add basic support for aliases also to DocBook and WebXML generators. - Document \typealias. Fixes: QTBUG-82712 Change-Id: Iafa8c7def0a7488d7521fbc2862290a9bb3167ff Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Port qdoc to QRegularExpressionLars Knoll2020-05-181-7/+7
| | | | | | | | | | Change-Id: I2c9eb349a92503afcdd41bacf556e561d9f8c098 Reviewed-by: Liang Qi <liang.qi@qt.io>
* | QDoc: const-ref variablePaul Wicking2020-05-051-1/+1
| | | | | | | | | | Change-Id: I4dce878e02cc88432e5c3032b725131d01d1db47 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | QDoc: default trivial con-/destructorPaul Wicking2020-05-051-16/+0
| | | | | | | | | | Change-Id: Ifbbf87b6c2a29da85db273d55ba98446dd246a9b Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | QDoc: Clean up includesPaul Wicking2020-05-041-3/+0
|/ | | | | | | | | * Remove unused includes * Replace deprecated C++ includes with counterpart. Task-number: QTBUG-71176 Change-Id: Ie3224d9f9c19fd8f93879de6c7604a8db421b88b Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Parse enum classes correctlyTopi Reinio2020-01-201-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | Clang provides us sufficient information to detect a scoped enum (an enum class). For such enums, include the enum type name into the fully qualified name of the enum values. For enums related to \headerfile nodes, drop the '<Header>::' from the qualified name of the enum values as they are not valid. Ensure that this also applies to all node types in Node::plainFullName(), as including file names into a qualified path is always incorrect. In some cases, enum classes were also forward declared. This was a problem as QDoc skipped the full declaration after seeing the forward one. Combat this by re-processing the enum declarations that do not contain any values yet. Add relevant test case. [ChangeLog][qdoc] QDoc now generates correct documentation for enum classes. Fixes: QTBUG-66740 Change-Id: I36dcb3393500acb788e0a305fd0dfecc4b58ebc3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Teach QDoc to output function and class template parametersTopi Reinio2020-01-201-2/+6
| | | | | | | | | | | | | | | | | | | Add a visitor functor that reconstructs template parameters from the Clang AST, and use it when either a class or a method template is detected. Store this information in the node - for now, they are used only in the class reference page subtitle (for classes), and detailed section of function documentation. Template parameters are not considered when searching/linking to entities, they are for display only. [ChangeLog][qdoc] Added capability to display class/method template parameters in the generated documentation. Fixes: QTBUG-17456 Change-Id: I300cc63b9fa20d4f6efaeaa27ea3769635a7b32c Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Simplify the code printing the enum valuesThibaut Cuvelier2019-12-191-17/+9
| | | | | Change-Id: I743baf96185fcb20ce740fcc9c2beb011f5bdefb Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* clang-format QDocPaul Wicking2019-12-171-58/+54
| | | | | | | | | | | | | | | | This patch is the result of formatting all of QDoc's source with clang-format. The clang-format style is from the qt5 super repo's _clang-format definition. The purpose is unify the style across the code, to avoid spending too much time on style related issues in reviews and cleanup patches. Future changes to QDoc can benefit from using git-clang-format in combination with the git commit hook provided in qtrepotools.git as mentioned in this email to the dev list: https://lists.qt-project.org/pipermail/development/2019-October/037682.html Change-Id: I8af6a051c8334b5f35862a4dcd3becce8ac500c2 Reviewed-by: Martin Smith <martin.smith@qt.io>
* QDoc: Use QVector instead of QListPaul Wicking2019-12-121-1/+1
| | | | | | | | | | | Replace the use of QVector in most of QDoc. Also, remove one redundant C-style cast to int for result from method call that returns an int. As this happened in a macro, the result is removing a whole bunch of nagging from code inspection. Fixes: QTBUG-80669 Change-Id: Ib1aed95e01eaddd1e1213a145e815a0c4753ac67 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDoc: Minor adjustment/cleanupPaul Wicking2019-12-111-4/+4
| | | | | | | Pre-increment instead of post-increment for efficiency and readability. Change-Id: I10b33360dd36cd1d0f4338441c1ad4724551e80e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Clean up loops with iteratorsPaul Wicking2019-12-101-5/+3
| | | | | | | | | | | - Use ranged-based fors where applicable. - Use auto keyword for iterators. - Move a few variable declarations to where they're to be used. - Update docs where applicable. Fixes: QTBUG-80536 Change-Id: I859440b96428dec4ef108b01d391479d3f8dbd83 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Adapt code to follow coding rulesThibaut Cuvelier2019-12-031-38/+27
| | | | | | Change-Id: I8e58dcecdc392c6fc26840f18d4b0e216941de27 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDoc: Use range-based for instead of foreachPaul Wicking2019-09-281-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change replaces the use of foreach with range-based for throughout QDoc. It also ensures that the loop body doesn't modify the container being iterated over, by: - Making a const copy when the container is a member variable or the result of an expression, and iterating over that copy. This is the preferred approach. - Using qAsConst() when the container is a (static) member variable or local to the method and not const. The latter is typical where the collection is sorted immediately before the loop. In two cases (doc.cpp), replaced Q_FOREACH + delete with qDeleteAll. In two cases (cppcodeparser.cpp), the range declaration is replaced within the loop statement. These rewrites express the behavior clearer than the original code. In two cases (codeparser.cpp), use a range-based for instead of a while loop where the condition is an iterator, for more expressive code. Finally, use the auto keyword where appropriate and improve a few variable names. QDoc warning count and generated output is unchanged after this refactoring. Change-Id: I64f02d24dca373a3a41402d535382e2c526bb55e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-09-271-2/+7
|\ | | | | | | Change-Id: I5c06b3e0177fcccd988620ab269f75632689a54c
| * qdoc: Do not prefix related non-members with a parent scopeTopi Reinio2019-09-121-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The fact that a related non-member has a parent-child relationship with the node it relates to is simply an implementation detail in QDoc - it should not be visible in the generated output. The same applies for proxy nodes - i.e. aggregates that hold children documented in another module. Fixes: QTBUG-77960 Change-Id: I8d83ee7022d5f15af720cbd65c138be0469d39a0 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
* | QDoc: Clean up whitespacePaul Wicking2019-08-081-9/+9
| | | | | | | | | | | | | | | | | | | | | | Ensure that QDoc conforms to Qt style, whitespace edition. For the most part, the change involves moving the pointer operators. Also remove whitespace following an opening parenthesis, or immediately preceding a closing one. In some cases, adjust the following line accordingly in methods that span multiple lines. Change-Id: I56ae125a2acf09c669c0a73dc814d05f13575f39 Reviewed-by: Martin Smith <martin.smith@qt.io>
* | QDoc: Ensure all includes are uniform and according to stylePaul Wicking2019-08-031-4/+7
|/ | | | | | | | | | | | | | | | | | | Housekeeping. Includes are organized after recommended best practice and organized in the following order: - include self (i.e. include own header) - include local files - include Qt, e.g. <QtCore/qstring.h> - include Qt private - include externals, e.g. stdio.h in alphabetic order within each block, aside from accommodating #if-ery, in which includes follow the block they belong to. Also, updated copyright notice to year of latest edit in each file. Change-Id: I1e6b215f172fd5373d57016f7678b88b9e73231e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qdoc: Correct function signatures from header filesMartin Smith2019-07-051-3/+6
| | | | | | | | | | This update fixes a regression where the signatures of global functions declared in header files were being erroneously qualified with the name of the header file. The incorrect qualification is removed. Task-number: QTBUG-76822 Change-Id: I59ddee9cdeb5cad45afab7f0b4a50e90bde1578c Reviewed-by: Topi Reiniö <topi.reinio@qt.io>