summaryrefslogtreecommitdiff
path: root/src/qdoc
diff options
context:
space:
mode:
authorJaishree Vyas <Jaishree.Vyas@qt.io>2023-03-01 11:59:11 +0100
committerJaishree Vyas <Jaishree.Vyas@qt.io>2023-04-19 11:45:58 +0200
commitb968ed6bc09d363f96ab6761f88fde790f7f09b1 (patch)
tree53bbaa68eaa921c4f2936f0e6fb1d70548c27438 /src/qdoc
parent263741618ba33be5cb69d3e63c1eafb566a77449 (diff)
downloadqttools-b968ed6bc09d363f96ab6761f88fde790f7f09b1.tar.gz
qdoc: Add \details command
The command \details generates a collapsible <details> element with a <summary> to control the hidden/visible state. The idea behind this is to provide more information with less text on our main pages. For output formats other than HTML, the details are rendered as a normal paragraph and the summary string is ignored. Pick-to: 6.5 Change-Id: Id5daddd4854f22b9ceaa9a55b98af94a1ba06039 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc')
-rw-r--r--src/qdoc/qdoc/atom.cpp4
-rw-r--r--src/qdoc/qdoc/atom.h2
-rw-r--r--src/qdoc/qdoc/doc/qdoc-manual-markupcmds.qdoc40
-rw-r--r--src/qdoc/qdoc/docbookgenerator.cpp3
-rw-r--r--src/qdoc/qdoc/docparser.cpp19
-rw-r--r--src/qdoc/qdoc/htmlgenerator.cpp10
6 files changed, 77 insertions, 1 deletions
diff --git a/src/qdoc/qdoc/atom.cpp b/src/qdoc/qdoc/atom.cpp
index 6b895769f..080a8fddd 100644
--- a/src/qdoc/qdoc/atom.cpp
+++ b/src/qdoc/qdoc/atom.cpp
@@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE
\value CodeBad
\value CodeQuoteArgument
\value CodeQuoteCommand
+ \value DetailsLeft
+ \value DetailsRight
\value DivLeft
\value DivRight
\value ExampleFileLink
@@ -130,6 +132,8 @@ static const struct
{ "CodeBad", Atom::CodeBad },
{ "CodeQuoteArgument", Atom::CodeQuoteArgument },
{ "CodeQuoteCommand", Atom::CodeQuoteCommand },
+ { "DetailsLeft", Atom::DetailsLeft },
+ { "DetailsRight", Atom::DetailsRight },
{ "DivLeft", Atom::DivLeft },
{ "DivRight", Atom::DivRight },
{ "ExampleFileLink", Atom::ExampleFileLink },
diff --git a/src/qdoc/qdoc/atom.h b/src/qdoc/qdoc/atom.h
index ba453254b..3e642a6dd 100644
--- a/src/qdoc/qdoc/atom.h
+++ b/src/qdoc/qdoc/atom.h
@@ -31,6 +31,8 @@ public:
CodeBad,
CodeQuoteArgument,
CodeQuoteCommand,
+ DetailsLeft,
+ DetailsRight,
DivLeft,
DivRight,
ExampleFileLink,
diff --git a/src/qdoc/qdoc/doc/qdoc-manual-markupcmds.qdoc b/src/qdoc/qdoc/doc/qdoc-manual-markupcmds.qdoc
index 04d9f7cc3..714db3664 100644
--- a/src/qdoc/qdoc/doc/qdoc-manual-markupcmds.qdoc
+++ b/src/qdoc/qdoc/doc/qdoc-manual-markupcmds.qdoc
@@ -173,6 +173,46 @@
See also \l {tt-command} {\\tt} and \l {code-command} {\\code}.
+ \target details-command
+ \section1 \\details
+
+ The \\details and \\enddetails commands generates a collapsible <details>
+ element with a <summary> to control the hidden/visible state.
+
+ When generating HTML output, use the \\details and \\enddetails commands to
+ generate a collapsible \c{<details>} HTML element. The command takes an
+ optional summary string enclosed in curly braces. This optional argument
+ specifies a visible heading for the details.
+
+ For example, with the following input:
+ \badcode *
+ /\1!
+ \details {QDoc details}
+ \note You're looking at detailed information.
+ \enddetails
+ \1/
+ \endcode
+
+ If QDoc is generating HTML, it will translate these commands to:
+
+ \badcode
+ <summary>QDoc details</summary><div class="admonition note"><p><b>Note: </b>You're looking at detailed information.</p></div>
+ \endcode
+
+ QDoc renders this as:
+
+ \raw HTML
+ <details>
+ <summary>QDoc details</summary>
+ <div class="admonition note">
+ <p><b>Note: </b>You're looking at detailed information.</p>
+ </div>
+ </details>
+ \endraw
+
+ For any other output format, QDoc generates the contents as a normal paragraph,
+ ignoring the summary string.
+
\target div-command
\section1 \\div
diff --git a/src/qdoc/qdoc/docbookgenerator.cpp b/src/qdoc/qdoc/docbookgenerator.cpp
index b849e5453..cc75cac07 100644
--- a/src/qdoc/qdoc/docbookgenerator.cpp
+++ b/src/qdoc/qdoc/docbookgenerator.cpp
@@ -341,6 +341,9 @@ qsizetype DocBookGenerator::generateAtom(const Atom *atom, const Node *relative)
m_writer->writeEndElement(); // programlisting
newLine();
break;
+ case Atom::DetailsLeft:
+ case Atom::DetailsRight:
+ break;
case Atom::DivLeft:
case Atom::DivRight:
break;
diff --git a/src/qdoc/qdoc/docparser.cpp b/src/qdoc/qdoc/docparser.cpp
index c638cde4e..6702d8ed2 100644
--- a/src/qdoc/qdoc/docparser.cpp
+++ b/src/qdoc/qdoc/docparser.cpp
@@ -36,11 +36,13 @@ enum {
CMD_CAPTION,
CMD_CODE,
CMD_CODELINE,
+ CMD_DETAILS,
CMD_DIV,
CMD_DOTS,
CMD_E,
CMD_ELSE,
CMD_ENDCODE,
+ CMD_ENDDETAILS,
CMD_ENDDIV,
CMD_ENDFOOTNOTE,
CMD_ENDIF,
@@ -136,11 +138,13 @@ static struct
{ "caption", CMD_CAPTION },
{ "code", CMD_CODE },
{ "codeline", CMD_CODELINE },
+ { "details", CMD_DETAILS },
{ "div", CMD_DIV },
{ "dots", CMD_DOTS },
{ "e", CMD_E },
{ "else", CMD_ELSE },
{ "endcode", CMD_ENDCODE },
+ { "enddetails", CMD_ENDDETAILS },
{ "enddiv", CMD_ENDDIV },
{ "endfootnote", CMD_ENDFOOTNOTE },
{ "endif", CMD_ENDIF },
@@ -382,6 +386,16 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate,
getCode(CMD_QML, CodeMarker::markerForLanguage(QLatin1String("QML")),
getMetaCommandArgument(cmdStr)));
break;
+ case CMD_DETAILS:
+ leavePara();
+ append(Atom::DetailsLeft, getArgument());
+ m_openedCommands.push(cmd);
+ break;
+ case CMD_ENDDETAILS:
+ leavePara();
+ append(Atom::DetailsRight);
+ closeCommand(cmd);
+ break;
case CMD_DIV:
leavePara();
p1 = getArgument(true);
@@ -1749,7 +1763,8 @@ void DocParser::enterPara(Atom::AtomType leftType, Atom::AtomType rightType, con
if (m_paragraphState == OutsideParagraph) {
if ((m_private->m_text.lastAtom()->type() != Atom::ListItemLeft)
- && (m_private->m_text.lastAtom()->type() != Atom::DivLeft)) {
+ && (m_private->m_text.lastAtom()->type() != Atom::DivLeft)
+ && (m_private->m_text.lastAtom()->type() != Atom::DetailsLeft)) {
leaveValueList();
}
@@ -2425,6 +2440,8 @@ int DocParser::endCmdFor(int cmd)
return CMD_ENDCODE;
case CMD_CODE:
return CMD_ENDCODE;
+ case CMD_DETAILS:
+ return CMD_ENDDETAILS;
case CMD_DIV:
return CMD_ENDDIV;
case CMD_QML:
diff --git a/src/qdoc/qdoc/htmlgenerator.cpp b/src/qdoc/qdoc/htmlgenerator.cpp
index 74ce2be7e..304989f9c 100644
--- a/src/qdoc/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/qdoc/htmlgenerator.cpp
@@ -370,6 +370,16 @@ qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, Co
m_codePrefix, m_codeSuffix)
<< "</pre>\n";
break;
+ case Atom::DetailsLeft:
+ out() << "<details>\n";
+ if (!atom->string().isEmpty())
+ out() << "<summary>" << protectEnc(atom->string()) << "</summary>\n";
+ else
+ out() << "<summary>...</summary>\n";
+ break;
+ case Atom::DetailsRight:
+ out() << "</details>\n";
+ break;
case Atom::DivLeft:
out() << "<div";
if (!atom->string().isEmpty())