QDoc Examples: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Integrating Examples=
h1. Integrating Examples


This page is part of the [[QtWritingGuidelines|Qt Writing Guidelines]].
This page is part of the [[QtWritingGuidelines| Qt Writing Guidelines]].


This guide discusses the best and effective ways to integrade examples into Qt 5. Though there are exceptions, following the guidelines ensures consistency, leading to easier maintenance and ensuring that the end-user accesses the content.
This guide discusses the best and effective ways to integrade examples into Qt 5. Though there are exceptions, following the guidelines ensures consistency, leading to easier maintenance and ensuring that the end-user accesses the content.


==Overview of Elements==
== Overview of Elements ==


Qt Examples are comprised of these main elements:
Qt Examples are comprised of these main elements:<br />* source code, including project files<br />* documentation, such as tutorials and example documentation<br />* manifest files, QDoc configuration, and highlighting specific examples


* source code, including project files
The following pages address the first two elements, therefore make sure you read them first:<br />* [[Qt_Documentation_Structure | Qt Documentation Structure]] - where to put the source code, relative to the module<br />* [[ExamplesDocumentationStyle | Writing Qt Examples]]
* documentation, such as tutorials and example documentation
* manifest files, QDoc configuration, and highlighting specific examples


The following pages address the first two elements, therefore make sure you read them first:
== QDoc and Package Configuration ==


* [[Qt Documentation Structure]] – where to put the source code, relative to the module
Consult [[Qt_Documentation_Structure | Qt Documentation Structure]] to see where you should place the source files and documentation files. Afterwards, ensure that QDoc can see the example files by checking the project's ''qdocconf'' file.
* [[ExamplesDocumentationStyle|Writing Qt Examples]]
 
==QDoc and Package Configuration==
 
Consult [[Qt Documentation Structure]] to see where you should place the source files and documentation files. Afterwards, ensure that QDoc can see the example files by checking the project’s ''qdocconf'' file.


The following sections provide guidelines regarding various QDoc variables.
The following sections provide guidelines regarding various QDoc variables.


===Examples Source Directory===
=== Examples Source Directory ===


The '''exampledirs''' variable sets the location where QDoc looks for examples and their documentation. Specifically, QDoc uses the exampledirs variables ''and'' the '''\example''' QDoc command to find and form the page <span class="caps">URL</span>s for the example documentation.
The '''exampledirs''' variable sets the location where QDoc looks for examples and their documentation. Specifically, QDoc uses the exampledirs variables ''and'' the * QDoc command to find and form the page URLs for the example documentation.


For example, suppose that an example called ''Simple Code'' has the following documentation:<br /> and consider that the exampledirs variable is set to '''variousexample'''.<br /> QDoc then assumes that the example is in the directory '''variousexample/simplecode'''. QDoc uses this information to form the <span class="caps">HTML</span> pages as well.
For example, suppose that an example called ''Simple Code'' has the following documentation:<br /><code><br />simplecode<br />imple Code Example<br /></code><br />and consider that the exampledirs variable is set to '''variousexample'''.<br />QDoc then assumes that the example is in the directory '''variousexample/simplecode'''. QDoc uses this information to form the HTML pages as well.


'''Note''': The exampledirs variable is usually set using a relative path.
'''Note''': The exampledirs variable is usually set using a relative path.


===Example Installation Path===
=== Example Installation Path ===


Each module or QDoc project sets the '''examplesinstallpath''' variable (in ''.qdocconf'' files), which determines where the examples are located in the downloaded Qt packages.
Each module or QDoc project sets the '''examplesinstallpath''' variable (in ''.qdocconf'' files), which determines where the examples are located in the downloaded Qt packages.


For example, Qt Quick’s install path is ''quick'':<br /> Therefore, examples in Qt Quick are installed under the ''quick'' directory. In Qt 5.3 packages, examples are in ''C:\Qt\Qt5.3.1\Examples\Qt-5.3\quick'' (when the default installation directory is used).
For example, Qt Quick's install path is ''quick'':<br /><code><br />examplesinstallpath = quick<br /></code><br />Therefore, examples in Qt Quick are installed under the ''quick'' directory. In Qt 5.3 packages, examples are in ''C:5.3.1\Examples\Qt-5.3\quick'' (when the default installation directory is used).


===Thumbnail Images===
=== Thumbnail Images ===


Every example require a thumbnail image in the documentation. This thumbnail is then used in Qt Creator’s example pages.<br /> For non-visual examples such as command-line examples, you may bypass the thumbnail image by listing the example in the '''manifestmeta.thumbnail.names''' variable.
Every example require a thumbnail image in the documentation. This thumbnail is then used in Qt Creator's example pages.<br />For non-visual examples such as command-line examples, you may bypass the thumbnail image by listing the example in the '''manifestmeta.thumbnail.names''' variable.


For example, in Qt Quick’s qdocconf file:<br /> The Threaded ListModel Example has a generic Qt image as its thumbnail.
For example, in Qt Quick's qdocconf file:<br /><code><br />manifestmeta.thumbnail.names += &quot;QtQuick/Threaded ListModel Example&amp;quot;<br /></code><br />The Threaded ListModel Example has a generic Qt image as its thumbnail.


'''Note:''' The ''QtQuick/Threaded ListModel Example'' portion from the snippet above denotes the module name and the example title name and ''not'' the directory names.
'''Note:''' The ''QtQuick/Threaded ListModel Example'' portion from the snippet above denotes the module name and the example title name and ''not'' the directory names.


===Highlighted and Tagged Examples===
=== Highlighted and Tagged Examples ===


To declare that an example is highlighted or for a specific platform, add the example to the '''manifestmeta''' variables. There is a master list in qtbase’s '''doc/global/manifest-meta.qdocconf''' file.
To declare that an example is highlighted or for a specific platform, add the example to the '''manifestmeta''' variables. There is a master list in qtbase's '''doc/global/manifest-meta.qdocconf''' file.


Qt Creator will then display the examples and the tags in its Example mode. The user can then search for those examples using the tags.
Qt Creator will then display the examples and the tags in its Example mode. The user can then search for those examples using the tags.


===Committing and Using Codereview===
=== Committing and Using Codereview ===
 
Examples have to pass the Qt CI process (see [[Commit Policy|Commit_Policy]]) and these are some things to consider:


* Some repositories may not ''see'' the example files. Check that the examples is not in the .gitignore file.
Examples have to pass the Qt CI process (see [[Commit_Policy]]) and these are some things to consider:<br />* Some repositories may not ''see'' the example files. Check that the examples is not in the .gitignore file.<br />* Check for licenses and that the code follows the [[Commit_Policy]].
* Check for licenses and that the code follows the [[Commit Policy|Commit_Policy]].
* Make sure that the example compiles. Add the example and the directory in the parent directories’ ''.pro'' files as subdirs. Read the qmake Manual for more information: http://doc.qt.io/qt-5/qmake-manual.html

Revision as of 10:53, 24 February 2015

h1. Integrating Examples

This page is part of the Qt Writing Guidelines.

This guide discusses the best and effective ways to integrade examples into Qt 5. Though there are exceptions, following the guidelines ensures consistency, leading to easier maintenance and ensuring that the end-user accesses the content.

Overview of Elements

Qt Examples are comprised of these main elements:
* source code, including project files
* documentation, such as tutorials and example documentation
* manifest files, QDoc configuration, and highlighting specific examples

The following pages address the first two elements, therefore make sure you read them first:
* Qt Documentation Structure - where to put the source code, relative to the module
* Writing Qt Examples

QDoc and Package Configuration

Consult Qt Documentation Structure to see where you should place the source files and documentation files. Afterwards, ensure that QDoc can see the example files by checking the project's qdocconf file.

The following sections provide guidelines regarding various QDoc variables.

Examples Source Directory

The exampledirs variable sets the location where QDoc looks for examples and their documentation. Specifically, QDoc uses the exampledirs variables and the * QDoc command to find and form the page URLs for the example documentation.

For example, suppose that an example called Simple Code has the following documentation:

<br />simplecode<br />imple Code Example<br />


and consider that the exampledirs variable is set to variousexample.
QDoc then assumes that the example is in the directory variousexample/simplecode. QDoc uses this information to form the HTML pages as well.

Note: The exampledirs variable is usually set using a relative path.

Example Installation Path

Each module or QDoc project sets the examplesinstallpath variable (in .qdocconf files), which determines where the examples are located in the downloaded Qt packages.

For example, Qt Quick's install path is quick:

<br />examplesinstallpath = quick<br />


Therefore, examples in Qt Quick are installed under the quick directory. In Qt 5.3 packages, examples are in C:5.3.1\Examples\Qt-5.3\quick (when the default installation directory is used).

Thumbnail Images

Every example require a thumbnail image in the documentation. This thumbnail is then used in Qt Creator's example pages.
For non-visual examples such as command-line examples, you may bypass the thumbnail image by listing the example in the manifestmeta.thumbnail.names variable.

For example, in Qt Quick's qdocconf file:

<br />manifestmeta.thumbnail.names += &quot;QtQuick/Threaded ListModel Example&amp;quot;<br />


The Threaded ListModel Example has a generic Qt image as its thumbnail.

Note: The QtQuick/Threaded ListModel Example portion from the snippet above denotes the module name and the example title name and not the directory names.

Highlighted and Tagged Examples

To declare that an example is highlighted or for a specific platform, add the example to the manifestmeta variables. There is a master list in qtbase's doc/global/manifest-meta.qdocconf file.

Qt Creator will then display the examples and the tags in its Example mode. The user can then search for those examples using the tags.

Committing and Using Codereview

Examples have to pass the Qt CI process (see Commit_Policy) and these are some things to consider:
* Some repositories may not see the example files. Check that the examples is not in the .gitignore file.
* Check for licenses and that the code follows the Commit_Policy.