QDoc Style Guidelines: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=QDoc Style Guidelines=
h1. QDoc Style Guidelines


This page is part of the [[QtWritingGuidelines|Qt Writing Guidelines]]<br /> Though there are exceptions, following the guidelines ensures consistency across modules and Qt tools.
This page is part of the [[QtWritingGuidelines | Qt Writing Guidelines]]<br />Though there are exceptions, following the guidelines ensures consistency across modules and Qt tools.


==QDoc Commands and Whitespace==
== QDoc Commands and Whitespace ==


Here are some basic guidelines for using QDoc commands:
Here are some basic guidelines for using QDoc commands:


* Use the title of the page, class, or <span class="caps">QML</span> type with the \l command and not the <span class="caps">HTML</span> file name.
* Use the title of the page, class, or QML type with the command and not the HTML file name.  
* The space between the command and the left curly bracket is not needed and adds extra whitespace. Example: <br />''\l{Page Title}'' is more compact than ''\l {Page Title}''.
* The space between the command and the left curly bracket is not needed and adds extra whitespace. Example:<br />''{Page Title}'' is more compact than ''{Page Title}''.
* It is best to have the contents within '''{}''' in one line as this helps to spot errors and easier to search.
* It is best to have the contents within '''{}''' in one line as this helps to spot errors and easier to search.
* Documentation comments within .cpp or code files should follow the consistency and column width set by the surrounding code. It is set to 80 columns for Qt code (though exceptions exist).
* Documentation comments within .cpp or code files should follow the consistency and column width set by the surrounding code. It is set to 80 columns for Qt code (though exceptions exist).


==Markup and Code Blocks==
== Markup and Code Blocks ==


Marked up text notifies the reader that the text is special, either they are code or special keywords.
Marked up text notifies the reader that the text is special, either they are code or special keywords.


* '''\b''' – bold. Use bold to highlight special words. Limit the use of bold as it can attract too much attention.
* ''' - bold. Use bold to highlight special words. Limit the use of bold as it can attract too much attention.<br />''' ''' - emphasis. Emphasized words are typically rendered in italics, therefore, follow the regular American rules for emphasis or italicization. For example, use this command for special keywords followed by its definition.<br />''' ''' - code. See paragraph below about the use of code blocks.
* '''\e''' emphasis. Emphasized words are typically rendered in italics, therefore, follow the regular American rules for emphasis or italicization. For example, use this command for special keywords followed by its definition.
<br />These QDoc commands are for writing code to be typed by the developer:
* '''\c''' code. See paragraph below about the use of code blocks.
<br />''' ''' - the parameter for the ommand is displayed as monospace font, indicating it is code, return value, or a value used directly by the developer.<br />''' ''' and''' - content within the two commands are for writing code samples and is displayed in monospace font bound by a box. Syntax highlighting is enabled.
* ''' and''' - for valid (and parseable) QML code. QDoc may give warnings if the code is not parseable. Syntax highlighting is enabled.
* ''' and''' - Syntax highlighting disabled. Use this for command-line code or code outside of Qt (neither C+'', JavaScript, nor QML).. QDoc will not attempt to parse and highlight the code.
<br />These commands render their arguments in a specific way.<br />* ''' - See Also and creates a link to pages. Use to refer readers to similar topics.<br />''' ''' - Note. QDoc renders the parameter in bold. Use this command to refer to special information.<br />''' ''' - Warning. Similar to note, but use this command for information that can cause errors or warnings.
<br />h2. UI Texts
<br />Use''' to display UI texts. ''UI texts'' are displayed to the end-user, for example, the '''File''' in the file menu for many desktop applications. They are commonly used to direct the reader to click or read a particular text within their application. QDoc renders the text in bold.
<br />''' is also a valid command for UI text. However, it is deprecated and is recommended because its name and usage are closer to other documentation tools.


These QDoc commands are for writing code to be typed by the developer:
<br />h2. Brief Description with
 
<br />The brief description is displayed in the API pages and in annotated lists.
* '''\c''' – the parameter for the \c command is displayed as monospace font, indicating it is code, return value, or a value used directly by the developer.
<br />''' Due to compatibility reasons, the brief statement for C''+ API should start with &quot;The &lt;CLASS&amp;gt; class…&quot;.
* '''\code''' and '''\endcode''' – content within the two commands are for writing code samples and is displayed in monospace font bound by a box. Syntax highlighting is enabled.
* For QML API, the brief statement should start with &quot;&lt;VERB&amp;gt;…&quot;
* '''\qml''' and '''\endqml''' – for valid (and parseable) <span class="caps">QML</span> code. QDoc may give warnings if the code is not parseable. Syntax highlighting is enabled.
* For other pages, follow the style for QML brief descriptions.
* '''\badcode''' and '''\endcode''' – Syntax highlighting disabled. Use this for command-line code or code outside of Qt (neither C++, JavaScript, nor <span class="caps">QML</span>).. QDoc will not attempt to parse and highlight the code.
 
These commands render their arguments in a specific way.
 
* '''\sa''' – See Also and creates a link to pages. Use \sa to refer readers to similar topics.
* '''\note''' – Note. QDoc renders the parameter in bold. Use this command to refer to special information.
* '''\warning''' – Warning. Similar to note, but use this command for information that can cause errors or warnings.
 
==UI Texts==
 
Use '''\uicontrol''' to display UI texts. ''UI texts'' are displayed to the end-user, for example, the '''File''' in the file menu for many desktop applications. They are commonly used to direct the reader to click or read a particular text within their application. QDoc renders the text in bold.
 
'''\gui''' is also a valid command for UI text. However, it is deprecated and \uicontrol is recommended because its name and usage are closer to other documentation tools.
 
==Brief Description with \brief==
 
The brief description is displayed in the <span class="caps">API</span> pages and in annotated lists.
 
* Due to compatibility reasons, the brief statement for C++ <span class="caps">API</span> should start with “\brief The &lt;<span class="caps">CLASS</span>&gt; class…”.
* For <span class="caps">QML</span> <span class="caps">API</span>, the brief statement should start with “\brief &lt;<span class="caps">VERB</span>&gt;…”
* For other pages, follow the style for <span class="caps">QML</span> brief descriptions.
* Always terminate the brief with a period '''.'''.
* Always terminate the brief with a period '''.'''.


For more information, visit [[CppDocumentationStyle|C++ Documentation Style]] and [[QMLDocumentationStyle|<span class="caps">QML</span> Documentation Style]].
For more information, visit [[CppDocumentationStyle | C++ Documentation Style]] and [[QMLDocumentationStyle | QML Documentation Style]].


==Linking to other Pages or Sections==
== Linking to other Pages or Sections ==


The topic of linking is covered in a separate page: [[QDocLinkingGuidelines|QDoc Linking Guidelines]]
The topic of linking is covered in a separate page: [[QDocLinkingGuidelines | QDoc Linking Guidelines]]


==Table of Contents and Page Navigation==
== Table of Contents and Page Navigation ==


* '''\nextpage''' and '''\previouspage''' are for creating navigation links for a page. They should be written after the \title command but before the \brief command.
* ''' and''' are for creating navigation links for a page. They should be written after the ommand but before the command.
* Qt documentation hosted online and in Qt Creator is set up to utilize only '''\section1''', '''\section2''', and '''\section3''' as pages’ <span class="caps">CSS</span> only support three section levels.
* Qt documentation hosted online and in Qt Creator is set up to utilize only '''\section1''', '''\section2''', and '''\section3''' as pages' CSS only support three section levels.
* Projects not displayed within the Qt website may set the '''<span class="caps">HTML</span>.tocdepth''' variable in their respective QDoc <span class="caps">HTML</span> templates. For Qt 5, it is set to '''<span class="caps">HTML</span>.tocdepth = 2'''.
* Projects not displayed within the Qt website may set the '''HTML.tocdepth''' variable in their respective QDoc HTML templates. For Qt 5, it is set to '''HTML.tocdepth = 2'''.

Revision as of 11:21, 24 February 2015

h1. QDoc Style Guidelines

This page is part of the Qt Writing Guidelines
Though there are exceptions, following the guidelines ensures consistency across modules and Qt tools.

QDoc Commands and Whitespace

Here are some basic guidelines for using QDoc commands:

  • Use the title of the page, class, or QML type with the command and not the HTML file name.
  • The space between the command and the left curly bracket is not needed and adds extra whitespace. Example:
    {Page Title} is more compact than {Page Title}.
  • It is best to have the contents within {} in one line as this helps to spot errors and easier to search.
  • Documentation comments within .cpp or code files should follow the consistency and column width set by the surrounding code. It is set to 80 columns for Qt code (though exceptions exist).

Markup and Code Blocks

Marked up text notifies the reader that the text is special, either they are code or special keywords.

  • - bold. Use bold to highlight special words. Limit the use of bold as it can attract too much attention.
    - emphasis. Emphasized words are typically rendered in italics, therefore, follow the regular American rules for emphasis or italicization. For example, use this command for special keywords followed by its definition.
    - code. See paragraph below about the use of code blocks.


These QDoc commands are for writing code to be typed by the developer:
- the parameter for the ommand is displayed as monospace font, indicating it is code, return value, or a value used directly by the developer.
and - content within the two commands are for writing code samples and is displayed in monospace font bound by a box. Syntax highlighting is enabled.

  • and - for valid (and parseable) QML code. QDoc may give warnings if the code is not parseable. Syntax highlighting is enabled.
  • and - Syntax highlighting disabled. Use this for command-line code or code outside of Qt (neither C+, JavaScript, nor QML).. QDoc will not attempt to parse and highlight the code.


These commands render their arguments in a specific way.
* - See Also and creates a link to pages. Use to refer readers to similar topics.
- Note. QDoc renders the parameter in bold. Use this command to refer to special information.
- Warning. Similar to note, but use this command for information that can cause errors or warnings.
h2. UI Texts
Use to display UI texts. UI texts are displayed to the end-user, for example, the File in the file menu for many desktop applications. They are commonly used to direct the reader to click or read a particular text within their application. QDoc renders the text in bold.
is also a valid command for UI text. However, it is deprecated and is recommended because its name and usage are closer to other documentation tools.


h2. Brief Description with
The brief description is displayed in the API pages and in annotated lists.
' Due to compatibility reasons, the brief statement for C+ API should start with "The <CLASS&gt; class…".

  • For QML API, the brief statement should start with "<VERB&gt;…"
  • For other pages, follow the style for QML brief descriptions.
  • Always terminate the brief with a period ..

For more information, visit C++ Documentation Style and QML Documentation Style.

Linking to other Pages or Sections

The topic of linking is covered in a separate page: QDoc Linking Guidelines

Table of Contents and Page Navigation

  • and are for creating navigation links for a page. They should be written after the ommand but before the command.
  • Qt documentation hosted online and in Qt Creator is set up to utilize only \section1, \section2, and \section3 as pages' CSS only support three section levels.
  • Projects not displayed within the Qt website may set the HTML.tocdepth variable in their respective QDoc HTML templates. For Qt 5, it is set to HTML.tocdepth = 2.