summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodeparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* qdoc: properly implement \typealias commandTopi Reinio2020-04-231-2/+2
| | | | | | | | | | | | | | | | | | \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>
* qdoc: Fix regression in resolved example file pathsTopi Reinio2020-03-291-2/+1
| | | | | | | | | | | | | | | | | | A recent refactoring of code related to generation of example file lists caused a regression; if the parameter passed to an \example command contained subdirectories, e.g. \example tutorials/gettingstarted only the immediate example directory ('gettingstarted' above) was recorded in generated example lists and manifest files. Ensure that the file paths are prefixed with the full example location, and add a test to cover this. Fixes: QTBUG-83130 Change-Id: I061dcf6cd4e94a2c65e5a50a39f379759d7cd06f Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Remove commented out codePaul Wicking2020-03-261-1/+0
| | | | | Change-Id: Ie3c74010c62fa6c468732364bd1be77024fcca5b Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Extend \example command to consider CMake projectsVenugopal Shivashankar2020-03-201-52/+22
| | | | | | | | | | | | | | | | | | | | | | | QDoc looks for project file(s) in the example directories before generating docs for the example. Now that we are moving towards CMake, it's ideal that qdoc is aware of this new project file type. Refactor the code that looks for project files - add a new function to Config for this purpose, and store the project file name into ExampleNode. This allows removal of duplicated logic when generating the example-manifest.xml file. Add a unit test for Config::getExampleProjectFile(), and modify the generatedoutput test to cover output for a CMake-based example. [ChangeLog][qdoc] Added support for CMake-based example projects. Fixes: QTBUG-82908 Change-Id: If9f061c613fee94b35df277043c2f4df93da7ec0 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QDoc: Add warning to use of \contentspage commandv5.15.0-beta2Paul Wicking2020-03-111-1/+3
| | | | | | | | | | | The \contentspage command doesn't produce nav links to the contents page between the next and previous pages. QDoc hasn't generated these links in html output since Qt 5.3. Remove the documentation that refers to the command and add a warning that it should not be used.. Task-number: QTBUG-75170 Change-Id: Ib16fc1cbb1e661a7519ba650e655e209c3b45b68 Reviewed-by: Topi Reiniö <topi.reinio@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.15Qt Forward Merge Bot2020-01-281-0/+3
|\ | | | | | | Change-Id: I30a35e0998cd2538406ae5e11e2991f855f4ecb5
| * qdoc: Sort the members of shared comment node collectiveTopi Reinio2020-01-241-0/+3
| | | | | | | | | | | | | | | | | | Nodes sharing a comment will be listed together as a group, so sort them alphabetically. Fixes: QTBUG-81265 Change-Id: Ia8dcba92d74116bf6757bfc9aaded1c65d7271fd Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | qdoc: Make Config a singletonTopi Reinio2020-01-131-2/+3
|/ | | | | | | | | | | | There is no need to pass a pointer to Config throughout the API; the only instance of it is created in main() so we can turn it into a singleton. Having access to Config without API changes makes implementation of configurable features easier. Change-Id: Ida47e067865082dfe036a7a97f7f1ffc736db346 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* clang-format QDocPaul Wicking2019-12-171-188/+126
| | | | | | | | | | | | | | | | 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: Drop unnecessary sortPaul Wicking2019-12-111-2/+1
| | | | | | | | | There's no change in output by not sorting the container, so it seems to be entirely unnecessary. Also const qualify the container that is no longer sorted. Change-Id: I8d5186a70623b8db6397eb88b9b0a9b53465a34a Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDoc: Clean up loops with iteratorsPaul Wicking2019-12-101-25/+16
| | | | | | | | | | | - 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>
* qdoc: Fix issues with shared comment nodesTopi Reinio2019-10-161-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDoc stores <sharedcomment> elements to the .index correctly, but the nodes that were sharing a comment were added after the shared comment. This meant that a shared comment node (SCN) could not find any of its members as they hadn't been read in yet. Fix this by delaying the creation of a new SCN until we have a list of sharing nodes. Also fix other related issues: - Generate content also for non-function SCN members. - Make SCN adopt the genus of a member when adding one. - Fix Node::isPropertyGroup() to return true for actual property groups (not all QML properties that share a comment) and fix usage of that method. - Fix linking to property groups when searching by the group name. - Restore indentation of property group members both in the summary section and in the All Members file. Fixes: QTBUG-79204 Change-Id: I1702f39b178f52444436b800d4fe9cb99f976a60 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
* QDoc: Use range-based for instead of foreachPaul Wicking2019-09-281-6/+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>
* QDoc: Clean up whitespacePaul Wicking2019-08-081-38/+38
| | | | | | | | | | | 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-6/+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>
* QDoc: Fix typo in warningPaul Wicking2019-07-311-1/+1
| | | | | Change-Id: If39e90e516017b21454a85bf6a88489f470894ae Reviewed-by: Martin Smith <martin.smith@qt.io>
* Eradicate the last Java-style iterators and mark the module free of themMarc Mutz2019-07-121-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and of QLinkedList. The change in QDesignerAbstractPropertySheetFactory is straight-forward. The rest are little buggers: - In macdeployqt, the code iterates inside an if. Weird, but portable. - In CppCodeParser, it's still somewhat harmless: just a call to std::remove_if to avoid running into quadratic complexity, even though the original loop had a good idea of iterating backwards, saving at least some copies in the process. Need to take care there that we continue to find the _first_ main.cpp, not the last, so add a check for mainCpp.isEmpty(). - In QtGradientStopsModel, however, needed to work around the absence of QMap::rbegin()/rend(), and it shows why they're missing: QMap's funky op* makes it impossible to just use std::reverse_iterator to do the heavy lifting. Use the recently-added QKeyValueIterator to get an approximation. I say 'approximation', because that one lacks operator->, so we need to use (*it).first, which brings back memories of Qt 2's iterators... Change-Id: I051e64b8d36b04ed2e7cf7695d9b797f08efaccb Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix deprecation warnings about deprecated container conversionsFriedemann Kleint2019-05-231-3/+5
| | | | | | | | | Fix warnings introduced by qtbase/92f984273262531f909ede17a324f546fe502b5c. Change-Id: Iaca85ad36591f7208f63305b885e7ff59c014a72 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qdoc: Make QDoc warn about undocumented public classesMartin Smith2019-05-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDoc was marking all undocumented public API elements as "internal" and "private" because most of these undocumented elements should not be documented. The standard way to tell QDoc not to warn about an undocumented elemewnt in the public API is to give it a QDoc comment with the command "\internl" in it. But it was decided this would require too much work to eliminate all the warnings, because there are so many undocumented elements in the Qt public API that we really don't want to be documented. So we decided to just mark them all as both internal and private in QDoc itself, and that eliminated a great many useless QDoc warnings. But it also meant that QDoc would no longer warn when a public element was left undocumented by mistake. This is most often seen in C++ classes that are in the public API but are not documented. QFutureInterface is an example of a class that is not documented but should be documented because it is useful. This change lets QDoc warn that a class in the public API was not documented with a \class comment. Special cases: 1. If the undocumented class has no members, don't warn that it was not documented with a \class comment. 2. If the undocumented class's name contains the word "Private" it is probably not meant to be in the public API, so don't warn that it has no \class comment. 3. If the undocumented class has no function members, then don't warn that it has no \class comment. 4. If the undocumented class is marked DontDocument, then don't warn that it has no \class comment. The other part of this change relates to item 4 above. To mark a class or struct as DontDocument required adding a new topic command to QDoc. The new topic command is \dontdocument. The argument to this command is a list of class and struct names. The list is enclosed in parentheses. For example: \dontdocument (QMacAutoReleasePool QIncompatibleFlag ... QTextCodec::ConverterState QThreadStorageData) QDoc looks up each name in the list and marks it DontDocument. The documentation generator then sees the node is marked DontDocument and ignores the node. This makes it a lot easier to tell QDoc which public classes and structs should not generate the warning about no documentation. Task-number: QTBUG-57183 Change-Id: I7eee48de03ca7aeb72c63ae90ba373503d41612d Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Allow QML/JS types with the same name as the parent modulev5.13.0-beta3Topi Reinio2019-04-161-2/+2
| | | | | | | | | | | | | QtMultimedia QML module contains a QML type QtMultimedia. QDoc was overriding one with the other because the search function returns both types of nodes (as they have the same genus, 'QML'). Fix this by checking that we actually found an existing type, not a module. Task-number: QTBUG-75186 Change-Id: Id7a151d6db137fd337e4dd68ebe7c8aa08ed80e0 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Allow namespace members to use \relatesMartin Smith2019-04-081-1/+2
| | | | | | | | | | It had been required that \relates could only be used to relate global entities to a class. This change allows \relates to be used in the comments of entities in a named namespace. There are several cases in qtextstream.cpp Change-Id: I17b61dbdaf6b6bd8c420a2fa1fd9deef6b7125dc Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Search for QML type before creating itMartin Smith2019-04-021-14/+17
| | | | | | | | | | | | | | | | | | | | 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>
* qdoc: Eliminate need for the property group commandsMartin Smith2019-04-021-131/+65
| | | | | | | | | | | | | | | We have been using the \qmlpropertygroup command to document complex properties. we also have the \jspropertygroup but it hasn't been used. However, we also have the shared comment concept, which we have used for documenting groups of functions. This update changes qdoc to use the shared comment concept for QML and JS property groups. The property groups commands are therefore no longer needed. But there are several uses of the \qmlpropertygroup command, and qdoc still recognizes these, although it uses the shared comment concept to handle them. The property group commands will be removed from the qdoc manual in a later update. Change-Id: Ie98638546756fd1a70067a7cd483c3b962c02954 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Add support for documenting pyside examplesVenugopal Shivashankar2019-03-121-6/+13
| | | | | | | | | | | | | | At the moment, qdoc cannot generate documentation for python examples as it expects a .pro or .qmlproject file for every \example command it finds. Since Qt Creator v4.9, developers can create a python project using the New Project wizard, which means qdoc could use the .pyproject file to verify the python example. Change-Id: Idcecdffe4f798bd1409123f988e3b826247aed72 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Improve function overload handlingTopi Reinio2019-02-131-1/+1
| | | | | | | | | | | | | | | When QDoc calls Aggregate::normalizeOverloads(), process \internal function nodes last. This ensures that they get assigned overload numbers higher than the public ones, and adding internal overloads no longer shuffle around the public HTML anchors (that are based on the overload numbers). Also, when searching for functions, ensure that we don't return an \internal overload if a matching public one exists. This gets rid of a number of linking warnings. Change-Id: Idaac077e2f88d310e3261bf5b4c3df33ca02f873 Reviewed-by: Martin Smith <martin.smith@qt.io>
* QDoc: Code cleanup, use nullptr for nullptr constantsPaul Wicking2019-02-081-9/+9
| | | | | | | | | | 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: Correct ref pages for inner classesMartin Smith2019-02-081-14/+33
| | | | | | | | | | | | | | | | | | | | | | This update corrects the documentation pages for classes, structs, and unions that are declared inside a class or a struct. In Qt, a struct is often declared inside a class. For such internal declarations, the requirements for making the inner entity available were incorrectly shown. All that is really necessary is to include the parent class. So the requirements for including the inner entity are now replaced with, for example, "Struct State is declared in class QAccessible," where QAccessible becomes a link to the reference page for that class. It was easier to implement this change by teaching qdoc to recognize structs and unions in addition to classes, so that is also included in this change. Change-Id: I1a0d46ef19a130506c7bcbf77b46e298f6ab2f71 Task-number: QTBUG-66872 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qdoc: Major clean-up of FunctionNode and parameter processingv5.13.0-alpha1Martin Smith2019-02-061-544/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Inline CodeParser::processCommonMetaCommand() in its one callerMartin Smith2019-01-301-3/+62
| | | | | Change-Id: Ia715d6f5685363e4ccc22172ea45e43f1da72a17 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Tidy up CppCodeParser::parseMacroArg() and clarify its documentationMartin Smith2019-01-301-42/+44
| | | | | | | | | An early return lets it declare its returned pointer later and a terser name for this variable is entirely sufficient. (This also prepares the ground for changing its return type and de-virtualising.) Change-Id: Ia94d810d341535d2d81aa28820696bfb2eec1652 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Skip NULL nodes when processing meta-commandsMartin Smith2019-01-291-11/+16
| | | | | | | | | Add a missing null-check to a loop over nodes. Tidied up handling of the case where the node is an Aggregate, in the process. Change-Id: Iec39efdc9565c730baa8e0118de7cef50acd84f8 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Inline various simple methods in QDocMartin Smith2019-01-231-16/+0
| | | | | Change-Id: Ie2ea694bd319f483e9a70f5934031028e0894976 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QDoc: filter out internal nodes when processing argsMartin Smith2019-01-231-13/+18
| | | | | | | | | | CppCodeParser::processTopicArgs() neglected to check whether nodes are internal (or internals are to be included) before including them. Add Doc::isInternal() and CodeParser::showInternal() to let it check this and add the check. Tidied up surrounding code in the process. Change-Id: I9e1ca379a8e58c1519c345bbf98f441915998061 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: Remove the \indexpage commandMartin Smith2018-12-031-4/+0
| | | | | | | | | The \indexpage command is no longer used. This update removes it from qdoc and from the qdoc manual. Change-Id: I7ac0cdc2d7fffc91dda01024740478e7da5570f0 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-103/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* qdoc: Remove support for \compat commandMartin Smith2018-06-011-23/+0
| | | | | | | | | The \compat command is no longer needed in QDoc, and the code that supports it makes some parts of QDoc needlessly complex. This update removes it, along with the documentation for it in the QDoc manual. Change-Id: I249b571e24ff8c3530d1ae5dbb4fff9186dba49d Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Document a namespace in multiple modulesMartin Smith2018-06-011-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qdoc didn't handle this. This update fixes most of what was wrong, but tuning the details of the namespace reference pages might follow. We have namespace Qt as an example. Most of the elements in the Qt namespace are in QtCore, but a few functions are declared in QtGui. Before this update, qdoc used the hack of using #ifdef to remove the declarations from qtextdocument.h in QtGui and .cpp and then added them back into qtnamespace.h and .cpp in QtCore. Now that hack is no longer necessary. The functions in the Qt namespace that are declared in QtGui are documented there, but the documentation is linked to from the namespace reference page, which remains in QtCore. That is, only one \namespace command is used to document the Qt namespace, and it appears in qnamespace.qdoc where it always did, but the documentation for the Qt namespace functions declared in QtGui is now appears in qtextdocument.cpp where it belongs. This also allows qdoc to report when a namespace contains elements that are public and documented, but the namespace itself is not documented, which was not possible before this change. qdoc also reports if a namespace is documented in more than one module. That is, for example, when \namespace Qt is used in both QtCore and QtGui. Note that this change will increase the number of qdoc warnings in QtBase, but the new warnings are expacted. Change-Id: If978a59209b7b2ae90713d3ae809ae03361df72f Task-number: QTBUG-67267 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Fix bugs in resolving inheritance and finding overridden functionsMartin Smith2018-02-231-22/+6
| | | | | | | | | | | | | | | | | | | | | A class node must have pointers to the class nodes of its base classes, but these pointers might not exist when qdoc creates the class node for the class. They might not exist until all the index files and include files have been parsewd. qdoc was trying to resolve the base classes too early. This update lets qdoc wait until it is known that everything has been built before attempting to resolve inheritance. This update also delays finding the pointer to the function node for the overridden function for a function marked "override" until the pointer is needed. Instead of storing the pointer to the node, the qualification path to the function is stored as a string, and the string is used to look up the overridden function when it is needed, which is only when the \reimp command is processed during output. The function that resolves the pointer to the overridden function was moved to the function node class, where it makes more sense. The way a few qdoc warnings are reported was also changed. Change-Id: Ia54642d11242386ae75139065f481e5d30f79fb5 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc/Config::findFile() Make userFriendlyFilePath an optional out parameterv5.11.0-alpha1Friedemann Kleint2018-02-141-10/+3
| | | | | | Task-number: PYSIDE-363 Change-Id: If076c9a77a5a11c05035f6fc30e6d68e60a35045 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Fix regression for wrongly reporting multiple topicsMartin Smith2018-02-051-0/+7
| | | | | | | | | | | | | | | We have the case where multiple different topic commands can appear in a qdoc comment in a .cpp file, when C++ is being documented as QML. Specifically, a \qmlpropertygroup command can be used with multiple \qmlproperty commands. The clang code parser was reporting this as an error, even though clang would never see these commaqndes because they are parsed by the old qdoc command parser. The hasTooManyTopics() function was changed to allow this case. It fixes many qdoc warnings in QtDeclarative. Change-Id: Iaea9a4b9c531f022544749819f65a48111ad0cc1 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Fix processing for \macro and QML method/signal topic commandsTopi Reinio2018-01-051-0/+122
| | | | | | | | | | | | | | | Because processing these commands do not use clang, their implementation is moved from ClangCodeParser to CppCodeParser - this ensures that these topic commands are processed also when they appear in .qdoc files (PureDocParser, used for .qdoc, derives from CppCodeParser). Also, these functions did nothing when qdoc was running in prepare phase which in turn meant that they were not written to .index, thus breaking cross-module linking for macros/QML methods/signals. That check is now removed and the functions always do their thing. Change-Id: I8d9333b02092708955b619b573254eda5d82f038 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Handle shared comments betterMartin Smith2017-11-161-62/+204
| | | | | | | | | | | | | | | The shared comment in qdoc was originally meant only for use with the \fn command, and only for multiple \fn commands in the same class. But it proved to be useful for other things, so people started using it in other contexts, even though it didn't work there. This update should handle them all. For example, when listing multiple \fn commands, they no longer need be for functions in the same class. Also, multiple \typedef commands are handled correctly. Change-Id: I4be86026a227d74822f5f2295577adf0fe170d49 Reviewed-by: Martin Smith <martin.smith@qt.io>
* Merge remote-tracking branch 'origin/wip/qdoc-clang' into devLiang Qi2017-11-131-1464/+79
|\ | | | | | | | | | | | | | | | | Conflicts: src/qdoc/cppcodeparser.h src/qdoc/location.cpp src/qdoc/qmlcodeparser.h Change-Id: I2e579ca5d83cd1c4b42acc9a07066d800cbc02cb
| * qdoc: This ends use of qdoc's old C++ parserMartin Smith2017-09-081-620/+2
| | | | | | | | | | | | | | | | | | | | This change replaces the last uses of qdoc's old, ad hoc C++ parser. Clang is now used for parsing all C++ code. \macro, \qmlxxx, and \jsxxx commands are parsed by simple pattern matching functions using QString::split(). Change-Id: If6f95b0487d1dd3206373bc55ec8e6b8b9c55b1e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * qdoc: Better support for multi-\fn documentation blocksMartin Smith2017-08-101-51/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change is a partial fix for the multi-\fn documentation concept. It outputs the documentation once but listing all the function signatures from the \fn commands found in the qdoc comment. Multiple \since commands are not implemented; the \until command is not implemented, and providing text applicable to a specific \fn signature is not implemented. This change requires clang, which means it requires a sequence of other updates as well, so you can't test it unless you have all that stuff. Task-number: QTBUG-60420 Change-Id: Ib316b6f97fa427ef730c4badfc785101bff55dce Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
| * qdoc: Make qdoc handle ref qualifiers correctlyMartin Smith2017-08-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This update makes qdoc parse and record the presence of ref qualifiers on the end of function declarations. It unfortunately increases the number of qdoc errors reported in QtBase, but that is because these functions are not documented correctly. There will be another update to qdoc to allow documenting multiple functions with a single comment, which is needed for documenting these ref qualified functions but also can be useful in other contexts. Change-Id: If2efb1a71c683a465d66608a20e238d84ea45d9a Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
| * qdoc: Teach parser for \fn commands to parse array parametersMartin Smith2017-08-101-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The old qdoc C++ parser is still used for parsing function signatures in \fn commands. The parser could not handle the case where a formal parameter is an array declaration. Now it parses the formal parameter, so the syntax errors have disappeared. But there is a separate problem involving the matching of the declaration to the same declaration in the header file, which is parsed by clang. However, this is a separate issue not addressed by this fix. Change-Id: I61be810b02ac50a6ee380664a41915cc85633c66 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>