summaryrefslogtreecommitdiff
path: root/src/qdoc/node.cpp
diff options
context:
space:
mode:
authorLuca Di Sera <luca.disera@qt.io>2022-09-08 13:02:24 +0200
committerLuca Di Sera <luca.disera@qt.io>2022-09-08 15:09:44 +0200
commitaf86681b123b6fa27e2a4586af80367d3b8b31f0 (patch)
treea6c3f7c9b79d45c33f3e64083c716430df6218fc /src/qdoc/node.cpp
parenta285decaf612f75229d8429891be1beef165994b (diff)
downloadqttools-af86681b123b6fa27e2a4586af80367d3b8b31f0.tar.gz
QDoc: Remove Node::PageType
QDoc uses a series of internal structure, based on an inheritance tree with base `Node`, to represent elements that are documentable and their properties. For documentable elements that generate a documentation page in the output, such as a documented C++ class, a subtree of the hierarchy, starting at `PageNode`, is used. A `PageNode`, and more generally a `Node`, can have a "Page Type", representing the type of element that the output documentation should represent. This is implemented in terms of an enumeration and an internal memeber of that enumeration. Supposedly, originally there was almost no hierarchy of types for `PageNode`s, and the enumeration was used as a form of tagged union to discern the the type of page that the `PageNode` would produce to determine the valid operations on it and the required computations that should have been performed during a generation. At some point in QDoc lifetime, some of the types implied by `PageType` were promoted to actual types under a `PageNode` hierarchy, for example `ExampleNode`, such that the use of `PageType` was reduced. Today, `PageType` is used only when parsing a "\page" command, which generates a `PageNode`. The "\page" command, which declares that a comment-block should generate a standalone documentation page in the output that doesn't document any specific or code-level element, takes an argument representing the name of the generated file and, optionally, a second argument. The optional second argument is a bare string that, if of a specific form, is used to define the type of the generated `PageNode` that represents the page. For example, a second argument of form "api" would mark the `PageNode` with as being of type `PageType::ApiPage`. Generally, this information is not used at all during the rest of a QDoc execution, as none of the remaining `PageType` nodes that don't have an actual type require special handling. There is, albeit, one exception to this. When the second argument of a "\page" command is "attribution", the `PageNode` has type `PageType::AttributionPage`. This type is meaningful as it is later used to collect "Attribution Pages" for a certain module so that QDoc can generate a list of them in Qt's documentation. "Attribution pages" are a special type of page that are used in Qt's documentation to "attribute" usages of third-party libraries, so as to comply with their licensing. Those pages are only expected to be generated by "qattributionscanner", which takes care of parsing json-defined attribution metadata for third-party libraries to generate the required attribution page. Thus, while `PageType` is generally not required, this specific behavior has to be supported. Hence, we remove `PageType`, replacing it with an equivalent behavior that only handles attributions. The `PageType` enum in `Node` is now removed. `Node::pageType`, the getter for the current `PageType` of `PageNode`, the two `Node::setPageType` overloads, the setter for the `PageType` of a `PageNode` and `Node::getPageType`, a converter from `Node::NodeType` to `Node::PageType`, were removed as they have no meaning anymore. The member `m_pageType` of `Node`, that contained the current "Page Type" of a `Node` instance, was removed as it lost its use. The constructor for `Node` is now modified to not set a `PageType`. The constructor for `PageNode` that took a `PageType` to set was removed, as it lost its use. As a consequence, the code that handles the "\page" command in `CppCodeParser::processTopicCommand`, was removed call the constructor for `PageNode` that does not require a `PageType`. Furthermore, the same code was modified to not process the second argument of a "\page" command anymore. The parsing and retrieval of the second argument is tied to the current model used by `DocParser`, which is general for topic commands, and cannot be easily removed, such that it will still be valid to pass a second argument albeit it will be completely ignored. The documentation in QDoc's manual that explains the usage of "\page"'s second argument was removed as a consequence. The code in `QDocIndexFiles` that writes and reads a `PageNode` was modified to ignore the type, where possible, while keeping a similar structure for the produced format. To preserve the "Attribution Pages" behavior, a new member, `is_attribution`, was introduced in `PageNode`, acting as a flag, defaulting to false, that is set when a `PageNode` is an "Attribution Page". A setter that turns on the flag, `markAttribution`, and a getter that reads the flag, `isAttribution`, were added to `PageNode`. Albeit in a more contained scope than the previous `Node` scope, the new members are too broadly scoped compared to their actual usages. For example, a `ClassNode` is allowed to be an "Attribution Page" albeit we don't expect that to make sense. Due to the low granularity of QDoc's internal representation, fixing this would either require a bigger refactoring or the introduction of new idioms, both of which are not an amount of work that is intended to be undertaken as of this patch. The code in `Aggregate::findAllAttribution`, that is used to build the list of "Attribution Pages" in a module, was modified to use the new methods to discern whether a child node is an "Attribution Page". A new command, "\attribution", was added to allow a user to mark a "\page" as an attribution. The command is not intended to take any arguments and will simply mark the documented page as being an "Attribution Page". No user-facing documentation for the command is provided as the command is intended only to support the internal "qattributionscanner" behavior in Qt's documentation and should not be used manually or in other places at the current time. The necessary code to handle the command was added to `CppCodeParser`, turning on the relevant flag when the command is found and producing a warning if the command is not in a "\page" comment-block. Due to the limited granularity of QDoc's datatypes, the command will incorrectly pass for non "\page", non `Aggregate` comment-block, such as "\example", where it could produce seemingly incorrect documentation. This is something that should be addressed separately in a general look at QDoc's internal structures. The code in `QDocIndexFiles::readIndexSection` that reads back a `PageNode` was modified to call `PageNode::markAttribution` when reading back a `PageNode` that is an attribution. The generator of QDoc's "Attribution Pages" for "qattributionscanner" was modified to output an "\attribution" command on the line following the "\page" command produced for an "Attribution Page" instead of generating an "attribution" argument for the "\page" command itself, to be compliant with the new interface. Change-Id: I41405fd4db884d98463a43bff8815c4504dc00ea Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/node.cpp')
-rw-r--r--src/qdoc/node.cpp90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index 4ab245efa..c9c248833 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -234,24 +234,6 @@ bool Node::nodeNameLessThan(const Node *n1, const Node *n2)
*/
/*!
- \enum Node::PageType
-
- An unsigned char value that indicates what kind of documentation page
- the Node represents. I think it is not very useful anymore.
-
- \value NoPageType
- \value AttributionPage
- \value ApiPage
- \value ArticlePage
- \value ExamplePage
- \value HowToPage
- \value OverviewPage
- \value TutorialPage
- \value FAQPage
- \omitvalue OnBeyondZebra
-*/
-
-/*!
\enum Node::FlagValue
A value used in PropertyNode and QmlPropertyNode that can be -1, 0, or +1.
@@ -615,49 +597,10 @@ Node::Node(NodeType type, Aggregate *parent, QString name)
m_outSubDir = Generator::outputSubdir();
- setPageType(getPageType(type));
setGenus(getGenus(type));
}
/*!
- Determines the appropriate PageType value for the NodeType
- value \a t and returns that PageType value.
- */
-Node::PageType Node::getPageType(Node::NodeType t)
-{
- switch (t) {
- case Node::Namespace:
- case Node::Class:
- case Node::Struct:
- case Node::Union:
- case Node::HeaderFile:
- case Node::Enum:
- case Node::Function:
- case Node::Typedef:
- case Node::Property:
- case Node::Variable:
- case Node::QmlType:
- case Node::QmlProperty:
- case Node::QmlValueType:
- case Node::SharedComment:
- return Node::ApiPage;
- case Node::Example:
- return Node::ExamplePage;
- case Node::Page:
- case Node::ExternalPage:
- return Node::NoPageType;
- case Node::Group:
- case Node::Module:
- case Node::QmlModule:
- case Node::Collection:
- return Node::OverviewPage;
- case Node::Proxy:
- default:
- return Node::NoPageType;
- }
-}
-
-/*!
Determines the appropriate Genus value for the NodeType
value \a t and returns that Genus value. Note that this
function is called in the Node() constructor. It always
@@ -791,27 +734,6 @@ QString Node::nodeTypeString(NodeType t)
return QString();
}
-/*!
- Set the page type according to the string \a t.
- */
-void Node::setPageType(const QString &t)
-{
- if ((t == "API") || (t == "api"))
- m_pageType = ApiPage;
- else if (t == "howto")
- m_pageType = HowToPage;
- else if (t == "overview")
- m_pageType = OverviewPage;
- else if (t == "tutorial")
- m_pageType = TutorialPage;
- else if (t == "faq")
- m_pageType = FAQPage;
- else if (t == "article")
- m_pageType = ArticlePage;
- else if (t == "example")
- m_pageType = ExamplePage;
-}
-
/*! Converts the boolean value \a b to an enum representation
of the boolean type, which includes an enum value for the
\e {default value} of the item, i.e. true, false, or default.
@@ -1135,18 +1057,6 @@ void Node::setDeprecatedSince(const QString &sinceVersion)
Sets this node's Genus to \a t.
*/
-/*! \fn PageType Node::pageType() const
- Returns this node's page type.
-
- \sa PageType
-*/
-
-/*! \fn void Node::setPageType(PageType t)
- Sets this node's page type to \a t.
-
- \sa PageType
-*/
-
/*! \fn QString Node::signature(bool values, bool noReturnType, bool templateParams) const
If this node is a FunctionNode, this function returns the function's