diff options
author | Kai Koehne <kai.koehne@qt.io> | 2019-04-02 09:46:30 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2019-04-02 11:55:53 +0000 |
commit | b8a6084861456f5448c0fd0c22e0192e83ffb5f0 (patch) | |
tree | b752d1e15677da9df7555914d941635914d09cbf | |
parent | ebda25ecb40aa1a13920a534bf2c6449981b92fe (diff) | |
download | qttools-b8a6084861456f5448c0fd0c22e0192e83ffb5f0.tar.gz |
qdoc: Add support for CMake comments
CMake uses # as a line comment marker. To detect CMake files
we check for the suffix .cmake, or check whether the filename
is "CMakeLists.txt".
See also
https://cmake.org/cmake/help/latest/manual/cmake-language.7.html
[ChangeLog][qdoc] qdoc now uses #! as a snippet marker in
.cmake, CMakeLists.txt files.
Task-number: QTBUG-73058
Change-Id: I230b113f0d49dd487b0f1926c815295a8a660a27
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r-- | src/qdoc/doc/qdoc-manual-markupcmds.qdoc | 5 | ||||
-rw-r--r-- | src/qdoc/quoter.cpp | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/qdoc/doc/qdoc-manual-markupcmds.qdoc b/src/qdoc/doc/qdoc-manual-markupcmds.qdoc index 1b6648f90..22b0b4e6b 100644 --- a/src/qdoc/doc/qdoc-manual-markupcmds.qdoc +++ b/src/qdoc/doc/qdoc-manual-markupcmds.qdoc @@ -1767,6 +1767,11 @@ ... \endcode + By default, qdoc looks for \c{//!} as a code snippet marker. + For \c{.pro}, \c{.py}, \c{.cmake}, and \c{CMakeLists.txt} + files, \c {#!} is detected. Finally, \c{<!--} is accepted in + \c{.html}, \c{.qrc}, \c{.ui}, \c{.xml}, \c{.dita}, and \c{.xq} files. + \target codeline-command \section1 \\codeline diff --git a/src/qdoc/quoter.cpp b/src/qdoc/quoter.cpp index 397caf085..408b1b5b0 100644 --- a/src/qdoc/quoter.cpp +++ b/src/qdoc/quoter.cpp @@ -112,7 +112,7 @@ Quoter::Quoter() /* We're going to hard code these delimiters: * C++, Qt, Qt Script, Java: //! [<id>] - * .pro, .py files: + * .pro, .py, CMake files: #! [<id>] * .html, .qrc, .ui, .xq, .xml .dita files: <!-- [<id>] --> @@ -120,6 +120,7 @@ Quoter::Quoter() if (!commentHash.size()) { commentHash["pro"] = "#!"; commentHash["py"] = "#!"; + commentHash["cmake"] = "#!"; commentHash["html"] = "<!--"; commentHash["qrc"] = "<!--"; commentHash["ui"] = "<!--"; @@ -339,8 +340,10 @@ void Quoter::failedAtEnd( const Location& docLocation, const QString& command ) QString Quoter::commentForCode() const { - QString suffix = QFileInfo(codeLocation.fileName()).suffix(); - return commentHash.value(suffix, "//!"); + QFileInfo fi = QFileInfo(codeLocation.fileName()); + if (fi.fileName() == "CMakeLists.txt") + return "#!"; + return commentHash.value(fi.suffix(), "//!"); } QString Quoter::removeSpecialLines(const QString &line, const QString &comment, int unindent) |