summaryrefslogtreecommitdiff
path: root/src/qdoc/qmlvisitor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QDoc: Move QDoc source files under a further "qdoc" directoryLuca Di Sera2023-04-121-709/+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: Always depend on QmlPrivatePaul Wicking2023-03-041-7/+2
| | | | | | | | | | | | | | | | | | | | | | Make Qml a hard dependency for QDoc. - There are no known usecases for running QDoc without qml support. - We're not testing QDoc without qml support, as it's not officially supported. - There are known issues with parsing certain file types when qml support is missing. - Dropping feature checks makes the code easier to reason about and thus maintain. - Clean up some of the configure and CMake configuration that's affected by the change. [ChangeLog][QDoc] QDoc now requires the library QmlPrivate. Make sure the qtdeclarative module is available. Fixes: QTBUG-111673 Change-Id: I3a8aa20ace3c379c3896b9f59aa4e8113cd9a873 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Make QDoc's output less noisy by defaultTopi Reinio2023-02-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | By default, QDoc printed progress information such as qt.qdoc: Start/Stop qdoc for <project> in <mode> qt.qdoc: Parse source files for <project> These do not provide much useful information, so hide them under the --log-progress command line option. --debug now also implies --log-progress. Remove all uses of leftover debug statements that used qDebug(), or where suitable, convert them to use logging category with qCDebug() and friends. Remove unused function FunctionNode::debug(). Clean up formatting and language for some of QDoc's output messages in passing. Fixes: QTBUG-110923 Pick-to: 6.5 Change-Id: I2cab456b0e144249e4234a253fd1c90d76666132 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Adapt to changes in QML ASTUlf Hermann2022-12-161-12/+2
| | | | | | | | | Signal arguments have proper types these days. Fixes: QTBUG-109456 Change-Id: Ib545173f51723e652b574e19b2b6723fd00476ae Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Unify handling of QML types and QML value typesTopi Reinio2022-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QML value types, formerly known as basic types, are nowadays provided by multiple modules and contain also properties and methods. QDoc's support for value types was rather basic (pun intended): No import/since statements nor sections for properties etc. was generated, the reference page had essentially a flat structure similar to a generic \page. As QML and QML value types are closely related, eliminate the dedicated Node subclass for value types (QmlValueTypeNode), handle both with QmlTypeNode class, differentiating them only with NodeType enumeration. Make Node::isQmlType() return true for both to provide similar behavior for all QML types, with a few exceptions: * Do not warn if \qmlvaluetype command is missing \inqmlmodule info as many of the original value types do not document it * Do not generate 'all members' file for value types as they're not expected to inherit other types. * Do not include the QML module name qualifier into the filenames generated for value types. This is done in order to keep the existing behavior for value types and to avoid creating redirects for online documentation. Related to the last point, remove code from Generator::fullDocumentLocation() that was never executed as it was a duplicate from Generator::fileBase(). Unifying the types under a single Node subclass allows for removal of multiple functions and code paths related to value types. They have some constraints compared to proper QML types, but QDoc does not currently enforce them. [ChangeLog][QDoc][QDoc now properly outputs documentation for QML value types with properties and methods.] Pick-to: 6.4 Fixes: QTBUG-109132 Change-Id: I418660b0a6e0461c82fd5cb67e4f955a0d9a712c Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-061-1/+1
| | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I234704ba429750ddee958a82f6c941d041da0653 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@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-24/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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: Fix build after changes to QQmlJS::AST::UiPublicMemberTopi Reinio2021-11-271-3/+3
| | | | | | | Change-Id: I9cdccdf96a84e5dc9c1956d63f019023cd7b2293 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qdoc: Improve function tagging for grouped \fn commandsTopi Reinio2021-08-231-2/+2
| | | | | | | | | | | | | | | | | | | QDoc provides a mechanism for tagging specific function declarations in a header with //! [tag] comments, allowing these tags to be referenced in an \fn command. This feature did not work for shared comment nodes containing multiple \fn commands, however. To make this work, we need to associate the 'bracketed args' (where the id tag is) with the command itself - previously it was stored in the Doc instance, but that doesn't work when there are multiple topic commands sharing a doc. To do so, repurpose the ArgLocPair structure to store the bracketed arg instead of a Location, as we never used this particular Location for anything, anyway. Pick-to: 6.2 Fixes: QTBUG-95948 Change-Id: Ic899d4252d705f84ba56ea201a55f3e5db068f00 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Fix incorrect parameters generated for QML signalsTopi Reinio2021-06-101-1/+1
| | | | | | | | | | If no \qmlsignal command was used, but a signal declaration in a QML file was preceded by its documentation comment, the signal parameters were malformed. Fixes: QTBUG-94395 Change-Id: Ie2f084009b4fb3f27602f170fab49601c19ab987 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QDoc: Code cleanupPaul Wicking2021-05-191-67/+67
| | | | | | | | | | | | | * Unify members; use s_ or m_ prefix instead of _ suffix. * Remove unnecessary member that duplicates content in base class. * Add [[nodiscard]] annotations where applicable. * Add overloads to virtual methods that have been extended with parameters with default values. * Make single argument ctors explicit. * Remove semi-colon from namespace declaration. Change-Id: Ie1ff39079722b81ba6754f945a898dc9b335bbae Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: Improve \deprecated commandPaul Wicking2021-05-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | | | | | | | | | | 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-27/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-2/+0
| | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | | 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: Re-implement \default commandTopi Reinio2021-03-171-0/+10
| | | | | | | | | | | | | | Marking a QML property as a default property is now done with \qmldefault command; repurpose the \default command to set a default value for a property. The default value is visible in the detailed property documentation as an extra 'default: <value>' attribute. The value is taken as-is from the argument passed to the command. Fixes: QTBUG-81525 Change-Id: I7a4395e6e96046facfc3d75cc62a3bd01d04935b Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Introduce \required command and handle REQUIRED for QML propertiesTopi Reinio2020-07-151-0/+5
| | | | | | | | | | | | | | | | | | | Q_PROPERTY macro now supports the REQUIRED keyword. This is relevant for QML types, where the type cannot be instatiated without declaring all required properties. Make QDoc parse the REQUIRED keyword, set associated QML property as required, and introduce a new command, \required, to do this explicitly in the docs. Likewise in QML visitor, check for the 'required' keyword for properties. [ChangeLog][qdoc] Support marking QML properties as required in the generated documentation. Fixes: QTBUG-85597 Change-Id: Ib8a25c5ebc1183812aec6e672b557c8fb1196741 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Port QtTools from QStringRef to QStringViewKarsten Heimrich2020-06-151-1/+1
| | | | | | Task-number: QTBUG-84319 Change-Id: Idb5a41172ea38b2f4edf385d67c1cdc2968a8d8c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDoc: Extract Aggregate from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: If28cc8b41401c90dfa48b613211b3d0a4dcd815a 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 FunctionNode from NodePaul Wicking2020-06-041-0/+1
| | | | | | Task-number: QTBUG-84578 Change-Id: I5967054a1c802ac6daf2622dcd4e4c8c4b3977ac Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Drop half-baked translation effortPaul Wicking2020-06-041-6/+7
| | | | | | | | | | | | | | The current implementation suffers from lack of maintenance. This causes a poor user experience that adds little value, or is even detrimental to perceived value. Work to improve the situation would have to be done at the expense of something else. This patch removes the Q_DECLARE_TR_FUNCTIONS macros from QDoc, and replaces calls to tr() with QStringLiteral(). Fixes: QTBUG-84568 Change-Id: I2df71c27246ca5de816608c887cf359db8f85900 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: QML parser: Fix parsing of function parametersTopi Reinio2020-05-141-1/+8
| | | | | | | | | | The parameter name was passed incorrectly as the default value, and the default value was not retrieved. Pick-to: 5.15 Fixes: QTBUG-84089 Change-Id: I9f35702b431da3e58a8cb422f0b41475dd99f604 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Fix parsing of QML signals that take parametersTopi Reinio2020-05-061-1/+1
| | | | | | | | | | | The signature of a QML signal can resemble that of a method, so we need to parse it as such. Fixes: QTBUG-84034 Pick-to: 5.15 Change-Id: I8506cd3c2cb469053c750ef6d2335cd1b85c3f1a Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Prepare for internal QML Parser API changeSimon Hausmann2020-03-021-6/+6
| | | | | | | | | | With the internal API version 8, the SourceLocation will move from QQmlJS::AST to the QQmlJS namespace, and it will get its loc.startLine/loc.startColumn members back. Change-Id: I70ba5a7f7b6eca60298a7b4982bf2cf099110089 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qdoc: Remove code for unimplemented command \pagekeywordsTopi Reinio2020-02-211-2/+0
| | | | | | | | | This undocumented command was storing a list of keywords in a node. Those keywords were never accessed. Task-number: QTBUG-82310 Change-Id: I144454667c78329a8a03ca81b9b90b047971d301 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Paul Wicking2019-12-181-106/+64
|\ | | | | | | Change-Id: I9ca43519bcad38f38f70eede4ee98b8028528259
| * clang-format QDocPaul Wicking2019-12-171-106/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-12-141-11/+5
|\ \ | |/ | | | | Change-Id: Iba365dc87ee3e96b2a44dad6bf4da436fd7b04f7
| * QDoc: Clean up loops with iteratorsPaul Wicking2019-12-101-11/+5
| | | | | | | | | | | | | | | | | | | | | | - 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>
* | Fix build after QML AST API changesSimon Hausmann2019-10-111-2/+6
|/ | | | | | | | | | | | | After commit bdc12f241118304a644f433bc3b75085c27a261d in qtdeclarative, the versionToken of UIImport does not exist anymore. It was incorrectly parsed and the version AST element provides the same information. Change-Id: I8d4a751a98c856ca3d8410c7ce7817a7ded0668f Fixes: QTBUG-79151 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QDoc: Get rid of old #if 0 blocksPaul Wicking2019-08-161-18/+0
| | | | | | | | | | Most of these have remained unchanged since 2015, so it seems it is simply not needed. In any case, these lines of code are all contained in the git history. Change-Id: I1bda6bc0aad61d59ec2f83de31d29e17d5255b71 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Clean up whitespacePaul Wicking2019-08-081-25/+25
| | | | | | | | | | | 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-7/+8
| | | | | | | | | | | | | | | | | | | 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>
* Eradicate some easy Java-style iteratorsMarc Mutz2019-06-181-6/+3
| | | | | | | | | Java-style iterators are scheduled for deprecation, or at the very least banned from use in Qt code. There are two more complicated ones left in the code for a later commit. Change-Id: I0c843ddcf2c67793b56ab99a219d36a0694c7b09 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* qdoc: Search for QML type before creating itMartin Smith2019-04-021-1/+6
| | | | | | | | | | | | | | | | | | | | Because we have QML types that represent C++ classes, it is possible for qdoc to process a \qmlproperty command before it has processed the \qmltype for the QML type where the QML property belongs. This is because the \qmlproperty command can appear in a different .cpp file from the one containing the \qmltype command. If the .cpp file is parsed first, the QML type node won't exist when the \qmlproperty is processed, resulting in a qdoc error. This update forces qdoc to always check for the exist of the QML type before creating it and before creating any QML properties for it, and if the QML type does not exist, create it. If it does exist, use it. Change-Id: I78705aa95ee5bf3abc2e17fb2b6cd52191d54b68 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-03-201-0/+11
|\ | | | | | | | | | | | | Conflicts: src/qdoc/configure.pri Change-Id: Iffd359fb2fa1480ea08253ef85bf2beff3ba188d
| * Handle recursion depth errors when parsing JavaScriptUlf Hermann2019-03-181-0/+11
| | | | | | | | | | | | | | | | Implementations of QQmlJS::AST::Visitor are required to do so. Fixes: QTBUG-74510 Change-Id: I061240f15ce082a05dd7829d225a5bfc3edd896a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QDoc: Code cleanup, use nullptr for nullptr constantsPaul Wicking2019-02-081-5/+5
| | | | | | | | | | | | | | | | | | | | Replace 0 as nullptr constant with nullptr. Remove reduntant semi-colons after member function definitions. Adjust whitespace on lines otherwise touched. Change-Id: I6af218ca8377611040360e0a3da392e7cffd29e9 Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | qdoc: Major clean-up of FunctionNode and parameter processingv5.13.0-alpha1Martin Smith2019-02-061-66/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This update was motivated by the need to correct two known issues in qdoc. First, linking to overloaded functions failed in some cases because the overloads were not numbered consistently, causing links to go to the wrong overload or to nowhere at all. Second, the mechanism for handling the \relates command didn't support using it to relate a function to more than one class. For example, there are many global qHash() functions spread around QtBase. Each is meant to compute a hash index for an object of some class type, so the object can be inserted into a QHash map for that class type. It is then desired to relate qHash(type Xxx, int seed) to both QHash<type> and class Xxx, so that the documentation for that qHash() function appears as a related non-member function of both QHash<type> and class Xxx. The example above also illustrates the overload numbering problem, because all these qHash() functions are overloads of the name qHash. To make matters worse, they are not all in the same module. Most of them are in QtCore, but a few are in QtNetwork, and this distribution problem will become worse over time as more qHash() functions are added. Prior to this update, qdoc was unable to relate a function to something in a different module, or it didn't always work. While designing a fix for these issues, it became clear that the processing of the FunctionNode and the function parameters would have to be rewritten. That's what this update does. These are the main points: 1. A new subclass of Node is added to act as a proxy for a class in another module. This ProxyNode acts as a place holder for the functions (and possibly other elements) that are related to a class in another module. This is used for the qHash() functions in QtNetwork that are related to QHash in QtCore. qdoc generates an html file named qtnetwork/qhash-proxy.html that contains the documentation for these functions. But these functions are listed as related non-members on the QHash class reference page in the qtcore output directory. They are listed there in the summary, but they link to the qhash-proxy.html page in qtnetwork. 2. A new, Parameters class is added to qdoc (parameters.h and parameters.cpp), and the class Parameter is moved there from node.h. class Parameters replaces the old QVector<Parameter> wherever it was used. This encapsulates all the parameter processing and matching in the Parameters class and simplifies the code at all the places where QVector<Parameter> had been used. 3. The assignment of overload numbers is now done in the normalizeOverloads() function, which is called after all the headers and sources have been processed but before the generate phase begins. This assignment is a simple renumbering now because all the overloads of a function are linked to each other via a nextOverload_ link in the FunctionNode. The first function named qHash() is inserted into the Aggregate node's function map, but subsequent qHash() FunctionNodes are not entered into the function map but are linked to the first qHash() via its nextOverload_ link. 4. The \relates command can now be used multiple times in a single qdoc comment. There remains some work to be done here because this currently only works for global entities, but there are several cases where \relates has been used in the qdoc comment of a member of a class. This will be fixed soon, I believe. When qdoc sees the first \relates Xxx command, for example for qHash(Yyy, seed), that qHash() is a child of the global namespace. qdoc allows it to remain as a child of the global namespace but it tells class Xxx to "adopt" that child (see Node::adoptChild()). This function makes this instance of qHash() be a child of class Xxx (in this case QHash<type>), so that the parent of this qHash() becomes Xxx. After this "adoption," qHash() is a child of both the global namespace and class Xxx, but qHash() only knows it is a child of Xxx, i.e. its parent pointer is Xxx. If this is the first qHash() to become a child of Xxx, it is inserted into the function map of Xxx, but its nextOverload_ link is not changed. This is because all the global qHash() functions have already been linked into the nextOverload_ linked list, and this list must not be changed. Hence, when qdoc searches for qHash(something) to make a link to it, it will find it as a child of the global namespace, but it will correctly link to it using its actual parent pointer. When qdoc sees the second \relates Yyy for this qHash() function, qdoc sees that this FunctionNode has already been made a related non-member of Xxx, so it can't let Yyy "adopt" it. Instead, it tells Yyy to clone this qHash(), which creates a shallow copy of it but resets its nextOverload_ pointer to nullptr. I believe this clone of qHash() won't be found in a search for a function named qHash(), because the global one (the adopted one) will be found first. Or, if it is found, a link to the clone will be generated, but that's ok because the documentation is identical. Note that the existence of qHash in two child lists is taken into account at destruction time. The only place where a Node is destroyed is in the destructor of Tree, which destroys the Node tree from the root down to the leaves. Each aggregate node is responsible for deleting each of its child nodes, but it only deletes a child node if it is the parent of that child node. All of the above revealed that some of the findFunctionNode() functions were either no longer needed or weren't being called in the first place, so they were deleted. This change is now ready for testing. Change-Id: I6da3e2e9e71d39a29d90e073ed614309a49e3d4c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Replace nodeType() comparisons to Node:X with isX() testsMartin Smith2019-01-221-1/+1
| | | | | | | | | | | | Change-Id: I62692b4b667a32fe77ee9dc51be15114aae9387b Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | qdoc: Do not print error for future functionsMartin Smith2018-12-031-41/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some function declarations are marked as not existing until Qt 6.0 in both the .h and .cpp files, but they are documented in the .cpp file. qdoc can't tie the documentation for these functions to their declarations because of the way clang is used, and qdoc reports that reports the documentation as an error. This update let's qdoc ignore these functions and not print the error when they are marked with \since 6.0. This will also work with other future versions. This update also collects all the uses of #define COMMAND_xxx in one location, which was partially required by the \since 6.0 change. Change-Id: I55052359f387406da340c748768f8e76c0b39d53 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | qdoc: Reorganize Qdoc's Node class hierarchyMartin Smith2018-10-231-32/+39
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a significant refactoring of QDoc's Node class hierarchy, which is meant to make maintenance of QDoc easier, and which will enable further development of QDoc as a library and plugin. Class DocumentNode is renamed to class PageNode, and it inherits the Node base class instead of inheriting class Aggregate. Class Aggregate inherits class PageNode instead of the Node base class. IOW, class DocumentNode and class Aggregate have swapped places in the class hierarchy, and DocumentNode has changed its name to PageNode. This makes the Node hierarchy more logical because: 1. Every entity that causes a documentation page to be written is a PageNode. 2. Only those PageNodes that can have children are Aggregates. Thus the HeaderFile subtype of the former DocumentNode has been promoted to class HeaderNode, which is a subclass of Aggregate. This makes sense because the old HeaderFile DocumentNode caused a documentation page to be generated, and that documentation page was very much like a class reference page. The \headerfile command is not used a lot in the Qt documentation but there are some useful cases, so it is worth making a subclass of Aggregate to handle them. The HeaderNode is now processed very much like the ClassNode and the NamespaceNode. Developers should be advised that isDocumentNode() is now isPageNode(), but isPageNode() can no longer be used to decide if an Aggregate* is a PageNode* (DocumentNode*), because Aggregate is now a subclass of PageNode. So a new convenience function is added: isTextPageNode(), which returns true if your Node* is a PageNode but not an Aggregate. IOW, isTextPageNode() returns true if the Node* is some kind of text page that doesn't represent a C++ or QML declaration. Class ExampleNode is a subclass of PageNode, not Aggregate. IOW, an ExampleNode no longer has children. Instead, the example files and example images that belong to the example are stored as string lists. It seems to work, but there might be problems in help files I haven't found yet. Class CollectionNode is now a subclass of Node instead of LeafNode. Class LeafNode is removed. All former subclasses of LeafNode are now subclasses of Node. This change also removes a lot of DITA bitrot. Work remaining to be done: 1. Remove the remaining DITA bitrot. 2. Consider letting QmlProperty and JsProperty be instances of Property and use the Genus value to distiguish them. 3. Also consider replacing QmlPropertyGroup and JsPropertyGroup with a single PropertyGroup and use the Genus value to distinguish them. This update also rearranges the parameters passed to the clang parser, and it removes some diff conflict lines that got saved by mistake. Change-Id: I918f83030c48d96db4a5588ab53458f221a5374e Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qmlvisitor: deal with PatternElement::bindingIdentifer as QStringRefShawn Rutledge2018-07-031-1/+1
| | | | | | | | | This also reverts commit 38e5f27de587e6c9cc3b2844af792289afcd2d07 and re-enables the build of the visitor. Change-Id: I4cb0a51d5019797d45370e959dd0fca5a3d23a74 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
* Compile qdoc with new JS parserLars Knoll2018-06-151-1/+1
| | | | | | | | | It compiles this way, but might not generate output that is fully correct in all cases. Task-number: QTBUG-67974 Change-Id: Ib4017a9b6b890295fa982753c766946bcadd3652 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Clean up the Parameter classMartin Smith2017-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way function signatures are specified is changing. A basic assumption of qdoc was that in the function signature specified with the \fn command, each formal parameter would have a name, and the name would be documentede in the text using the \a markup. This is no longer valid. There are now several cases in Qt where std::nullptr_t is used to specify a formal parameter, and no parameter name is provided. Furthermore, there are a few cases where some other type is used as the parameter type and no parameter name is given. The meaning in the first case is that the function must be called with NULL, and the meaning in the second case is that the parameter is not used in the function implementation. This clean up task must be accomplished in preparation for implementing the changes described above. The Parameter class had become a kludge. The so-called "rightType_" data member (which has not been used for quite a long time now and which was marked for removal long ago) is removed here. The change also affects the <parameter> element in the .index file, where the "right" item is removed and the "left" item is renamed to "type" . This index file change might break 3rd party applications that parse qdoc's index files, but I think there is only one, so be on the lookout for a complaint from that guy. Task-number: QTBUG-58277 Change-Id: I721bebdd5d0f2fcd65324373c3a3ec3ea1c33e26 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Fix build after changes to QtQMLJoerg Bornemann2016-12-021-3/+28
| | | | | | | | | | | | This patch supports building against declarative before and after commit 6ed23b91b949b7edaf96cdb0f2bba7b21a02de89. A template specialization is used instead of a function overload to avoid the compiler warning about unused functions and aborting the build. This can be simplified once qt5.git has been updated with declarative to contain the aforementioned commit. Change-Id: I9a1afdbaa70b6478bc5f51a833913fdc6cea1858 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>