/usr/share/qt5/doc/qdoc/06-qdoc-commands-includecodeinline.html is in qttools5-doc-html 5.9.5-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qdoc-manual-markupcmds.qdoc -->
<title>Including Code Inline | QDoc Manual 5.9</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
// loading style sheet breaks anchors that were jumped to before
// so force jumping to anchor again
setTimeout(function() {
var anchor = location.hash;
// need to jump to different anchor first (e.g. none)
location.hash = "#";
setTimeout(function() {
location.hash = anchor;
}, 0);
}, 0);
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td >Qt 5.9</td><td ><a href="qdoc-index.html">QDoc Manual</a></td><td >Including Code Inline</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.5 Reference Documentation</td>
</tr></table>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<link rel="prev" href="05-qdoc-commands-documentstructure.html" />
<link rel="next" href="07-0-qdoc-commands-includingexternalcode.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="05-qdoc-commands-documentstructure.html">Document Structure</a>
<span class="naviSeparator"> ◦ </span>
<a class="nextPage" href="07-0-qdoc-commands-includingexternalcode.html">Including External Code</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#code">\code</a></li>
<li class="level1"><a href="#badcode">\badcode</a></li>
<li class="level1"><a href="#newcode">\newcode</a></li>
<li class="level1"><a href="#oldcode">\oldcode</a></li>
<li class="level1"><a href="#qml">\qml</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Including Code Inline</h1>
<span class="subtitle"></span>
<!-- $$$06-qdoc-commands-includecodeinline.html-description -->
<div class="descr"> <a name="details"></a>
<p>The following commands are used to render source code without formatting. The source code begins on a new line, rendered in the code.</p>
<p><b>Note: </b>Although most of these commands are for rendering C++ code, the <a href="07-0-qdoc-commands-includingexternalcode.html#snippet-command">\snippet</a> and <a href="07-0-qdoc-commands-includingexternalcode.html#codeline-command">\codeline</a> commands are preferred over the others. These commands allow equivalent code snippets for other Qt language bindings to be substituted for the C++ snippets in the documentation.</p><a name="code-command"></a><a name="code"></a>
<h2 id="code">\code</h2>
<p>The \code and \endcode commands enclose a snippet of source code.</p>
<p><b>Note: </b>The <a href="04-qdoc-commands-textmarkup.html#c-command">\c</a> command can be used for short code fragments within a sentence. The \code command is for longer code snippets. It renders the code verbatim in a separate paragraph in a html <pre> element, and parses the enclosed snippet, creating links to any known types in the code.</p><p>For documenting command-line instructions, shell scripts, or any content that is not in a Qt language recognized by QDoc, use <a href="06-qdoc-commands-includecodeinline.html#badcode-command">\badcode</a> instead.</p>
<p>When processing any of the \code, <a href="06-qdoc-commands-includecodeinline.html#newcode-command">\newcode</a> or <a href="06-qdoc-commands-includecodeinline.html#oldcode-command">\oldcode</a> commands, QDoc removes all indentation that is common for the verbatim code blocks within a <code>/</code><code>*!</code> ... <code>*</code><code>/</code> comment before it adds the standard indentation.</p>
<p><b>Note: </b>This doesn't apply to externally quoted code using the <a href="07-0-qdoc-commands-includingexternalcode.html#quotefromfile-command">\quotefromfile</a> or <a href="07-0-qdoc-commands-includingexternalcode.html#quotefile-command">\quotefile</a> command.</p><pre class="cpp">
<span class="operator">/</span> <span class="operator">*</span><span class="operator">!</span>
\code
<span class="preprocessor">#include <QApplication></span>
<span class="preprocessor">#include <QPushButton></span>
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
{
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
\ endcode
<span class="operator">*</span> <span class="operator">/</span>
</pre>
<p>QDoc renders this as:</p>
<pre class="cpp">
<span class="preprocessor">#include <QApplication></span>
<span class="preprocessor">#include <QPushButton></span>
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
{
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
</pre>
<p>Other QDoc commands are disabled within \code... \endcode, and the special character '\' is accepted and rendered like the rest of the code.</p>
<p>To include code snippets from an external file, use the <a href="07-0-qdoc-commands-includingexternalcode.html#snippet-command">\snippet</a> and <a href="07-0-qdoc-commands-includingexternalcode.html#codeline-command">\codeline</a> commands.</p>
<p>See also <a href="04-qdoc-commands-textmarkup.html#c-command">\c</a>, <a href="06-qdoc-commands-includecodeinline.html#badcode-command">\badcode</a>, <a href="07-0-qdoc-commands-includingexternalcode.html#quotefromfile-command">\quotefromfile</a>, <a href="06-qdoc-commands-includecodeinline.html#newcode-command">\newcode</a>, and <a href="06-qdoc-commands-includecodeinline.html#oldcode-command">\oldcode</a>.</p>
<a name="badcode-command"></a><a name="badcode"></a>
<h2 id="badcode">\badcode</h2>
<p>Similar to <a href="06-qdoc-commands-includecodeinline.html#code-command">\code</a>, \badcode and \endcode commands enclose content that is rendered verbatim in a separate paragraph, but no parsing or automatic link creation is performed. Instead, the content is treated as plain text.</p>
<p>Substitute \code with this command when documenting command-line instructions, shell scripts or any other content that is not in a Qt language, but should still be styled similarly to a \code paragraph.</p>
<a name="newcode-command"></a><a name="newcode"></a>
<h2 id="newcode">\newcode</h2>
<p>The \newcode, \oldcode, and \endcode commands enable you to show how to port a snippet of code to a new version of an API.</p>
<p>The \newcode command and its companion the \oldcode command are a convenience combination of the <a href="06-qdoc-commands-includecodeinline.html#code-command">\code</a> commands: this combination provides a text relating the two code snippets to each other.</p>
<p>The \newcode command requires a preceding \oldcode statement.</p>
<p>Like the <a href="06-qdoc-commands-includecodeinline.html#code-command">\code</a> command, the \newcode command renders its code on a new line in the documentation using a monospace font and the standard indentation.</p>
<pre class="cpp">
<span class="operator">/</span> <span class="operator">*</span><span class="operator">!</span>
\oldcode
<span class="keyword">if</span> (printer<span class="operator">-</span><span class="operator">></span>setup(parent))
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
\newcode
<span class="type"><a href="../qtprintsupport/qprintdialog.html">QPrintDialog</a></span> dialog(printer<span class="operator">,</span> parent);
<span class="keyword">if</span> (dialog<span class="operator">.</span>exec())
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
\ endcode
<span class="operator">*</span> <span class="operator">/</span>
</pre>
<p>QDoc renders this as:</p>
<blockquote><p>For example, if you have code like</p>
<pre class="cpp plain">
if (printer->setup(parent))
...
</pre>
<p>you can rewrite it as</p>
<pre class="cpp">
<span class="type"><a href="../qtprintsupport/qprintdialog.html">QPrintDialog</a></span> dialog(printer<span class="operator">,</span> parent);
<span class="keyword">if</span> (dialog<span class="operator">.</span>exec())
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
</pre>
</blockquote>
<p>Other QDoc commands are disabled within \oldcode ... \endcode, and the '\' character doesn't need to be escaped.</p>
<a name="oldcode-command"></a><a name="oldcode"></a>
<h2 id="oldcode">\oldcode</h2>
<p>The \oldcode command requires a corresponding \newcode statement; otherwise QDoc fails to parse the command and emits a warning.</p>
<p>See also <a href="06-qdoc-commands-includecodeinline.html#newcode-command">\newcode</a>.</p>
<a name="qml-command"></a><a name="qml"></a>
<h2 id="qml">\qml</h2>
<p>The \qml and \endqml commands enclose a snippet of QML source code.</p>
<pre class="cpp">
<span class="operator">/</span> <span class="operator">*</span><span class="operator">!</span>
\qml
import <span class="type">QtQuick</span> <span class="number">2.0</span>
Row {
Rectangle {
width: <span class="number">100</span>; height: <span class="number">100</span>
color: <span class="string">"blue"</span>
transform: Translate { y: <span class="number">20</span> }
}
Rectangle {
width: <span class="number">100</span>; height: <span class="number">100</span>
color: <span class="string">"red"</span>
transform: Translate { y: <span class="operator">-</span><span class="number">20</span> }
}
}
\endqml
<span class="operator">*</span> <span class="operator">/</span>
</pre>
<p>QDoc renders this as:</p>
<pre class="qml">
import QtQuick 2.0
<span class="type">Row</span> {
<span class="type">Rectangle</span> {
<span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">color</span>: <span class="string">"blue"</span>
<span class="name">transform</span>: <span class="name">Translate</span> { <span class="name">y</span>: <span class="number">20</span> }
}
<span class="type">Rectangle</span> {
<span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">color</span>: <span class="string">"red"</span>
<span class="name">transform</span>: <span class="name">Translate</span> { <span class="name">y</span>: -<span class="number">20</span> }
}
}
</pre>
</div>
<!-- @@@06-qdoc-commands-includecodeinline.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="05-qdoc-commands-documentstructure.html">Document Structure</a>
<span class="naviSeparator"> ◦ </span>
<a class="nextPage" href="07-0-qdoc-commands-includingexternalcode.html">Including External Code</a>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|