Qt Writing Guidelines: Difference between revisions
Added link to https://wiki.qt.io/Enumerated_Qt_Writing_Guidelines |
No edit summary |
||
| Line 1: | Line 1: | ||
[[Category:Writing Guidelines]] | [[Category:Writing Guidelines]] | ||
The Qt Writing Guidelines contains information about writing Qt documentation in a consistent way. Though there are exceptions, maintain the consistency level outlined in the guidelines or the existing Qt documentation. | The Qt Writing Guidelines contains information about writing Qt documentation in a consistent way. Though there are exceptions, maintain the consistency level outlined in the guidelines or the existing Qt documentation. | ||
This guideline is maintained by the Qt Documentation Team, with members across the different Qt Group sites. Visit their page at: [[Contributing to Qt Documentation]] | This guideline is maintained by the Qt Documentation Team, with members across the different Qt Group sites. Visit their page at: [[Contributing to Qt Documentation]] | ||
== | == Purpose and scope == | ||
This page is the short entry point for anyone who writes Qt documentation. It covers the decisions a writer makes first, and each section ends with a link to the detailed rules. | |||
''''' | The Qt documentation is written in a source format that a tool called '''QDoc''' reads. QDoc turns documentation comments in C++ and QML source files, and separate <code>.qdoc</code> files, into the HTML pages on doc.qt.io. QML is the declarative language that Qt Quick applications use. A command that starts with a backslash, such as <code>\brief</code>, tells QDoc what a piece of text is. | ||
To make your first documentation change, follow these steps in order: find the source file that holds the text, edit it, run QDoc and Vale on it, and push the change to Gerrit. The sections [[#Checking your documentation|Checking your documentation]] and [[Contributing to Qt Documentation]] cover the last steps. Rules have IDs, such as R12 or G34. ''The letter R marks a rule that a tool checks using regular expressions, and G marks a rule that needs a person's judgment.'' | |||
Start with the three habits that fix most problems: write in active voice, put the main point of each paragraph first, and write section titles in sentence case. The example shows the first habit. | |||
{| class="wikitable" | {| class="wikitable" | ||
! Incorrect !! Correct | |||
! | |||
! | |||
|- | |- | ||
| | | Events are ignored by the item when it is disabled. || The item ignores events when it is disabled. | ||
| | |||
|} | |} | ||
When two sources disagree, follow the one that ranks higher: this page first, then [https://contribute.qt-project.org/quips/25 QUIP 25] (a Qt Project proposal document, here on documentation writing style), then the [[C++ Documentation Style]] and [[QML Documentation Style]] pages, then the Microsoft Writing Style Guide. The [https://doc.qt.io/qt-6/qdoc-index.html QDoc Manual] is the authority for command syntax, not for style. | |||
== | The full list of rules, each with a stable ID, is on the [[Qt Documentation Rules]] page. See [[Qt Documentation Rules#Sources|Sources]] for the ranking of sources. | ||
== Choosing the content type == | |||
A '''content type''' is the kind of page or text that you write. The type decides which rules apply, because an API reference entry and a tutorial step read differently. | |||
To choose the type, look at the QDoc command that opens the text. The main groups are: | |||
* API reference for C++ and QML, opened by commands such as <code>\class</code>, <code>\fn</code>, <code>\qmltype</code>, and <code>\qmlproperty</code> | |||
* Module pages, overviews, and concept pages, opened by <code>\module</code>, <code>\qmlmodule</code>, or <code>\page</code> | |||
* Examples, tutorials, and getting-started pages | |||
* Platform, deployment, porting, and tools pages | |||
* Commit messages and reports | |||
The [[Qt Documentation Rules#Content types|content-type table]] on the Rules page is the source of truth. It lists the detection pattern and the writing register of each type, and this page holds no second copy. A '''register''' is the way a type sounds: its person, tense, and sentence length. When a page fits no type, treat it as an overview page. | |||
See the content type rules in [[Qt Documentation Rules#Content types|Content types]]. | |||
== Language style == | |||
'''''Say the text out loud. If it sounds weird, then it is weird...and may need editing.''''' | |||
Qt uses the [https://learn.microsoft.com/en-us/style-guide/welcome/ Microsoft Writing Style Guide] in the Qt documentation. Use clear and direct language in '''American English'''. We write to a diverse audience and we need to communicate Qt topics in an approachable and understandable manner. | |||
Here are some specifics for Qt: | |||
''''' | # Use '''''active voice''''', not passive. Passive does not make a sentence formal, but unnecessarily weakens the sentence. See [https://learn.microsoft.com/en-us/style-guide/grammar/verbs Verbs] | ||
# Use the pronoun '''''you''''' to address the reader when appropriate. See [https://learn.microsoft.com/en-us/style-guide/grammar/nouns-pronouns Nouns and Pronouns]. | |||
# Use '''''because''''' instead of ''since'' or ''as''. See [https://learn.microsoft.com/en-us/style-guide/word-choice/use-simple-words-concise-sentences Use simple words, concise sentences]. | |||
# Use a serial comma, also known as the '''''Oxford comma'''''. See [https://learn.microsoft.com/en-us/style-guide/punctuation/commas Commas]. | |||
# Use the correct spelling and case for Qt Products. See [[Qt Terms and Concepts]]. | |||
# Be consistent with forming lists. The <code>\list</code> command starts a list, each item starts with <code>\li</code>, and <code>\endlist</code> closes it. Use the '''''same tone or mode''''' and be consistent about ending with periods. | |||
# Use US spelling and '''''avoid Latin abbreviations'''''. See [https://learn.microsoft.com/en-us/style-guide/word-choice/use-us-spelling-avoid-non-english-words Use US spelling and avoid non-English words]. For example, write ''that is'' instead of ''i.e.'', and ''for example'' instead of ''e.g.''. | |||
The [[Qt Documentation Rules#Substitutions and terminology|Substitutions and terminology]] section of the Rules page holds the full table of Latin terms and their replacements. | |||
=== Translated documentation === | |||
New in Qt 6.8, the Qt Reference Documentation is available in translated formats. Choose words that are simpler to translate or interpret. If the text is too complicated, then it may be poorly translated by translation tools. | |||
See [ | See the language rules in [[Qt Documentation Rules#Tool-checkable rules|Tool-checkable rules]] and [[Qt Documentation Rules#Judgment rules|Judgment rules]]. | ||
== Titles and headings == | |||
'''''Consistency is key...write sections in sentence-case, but maintain consistency with existing pages'''''. | |||
Write a section title as the argument to a <code>\section1</code> or <code>\section2</code> command. The <code>\section1</code> command starts a top-level section of a page, and <code>\section2</code> starts a subsection inside it. | |||
'''''Write section titles in sentence-case''''' as indicated by the ''Microsoft Writing Style Guide.'' See [https://learn.microsoft.com/en-us/style-guide/text-formatting/formatting-titles Formatting titles]. | |||
The previous guideline about using '''''title-case is no longer valid''''', but maintain consistency within the page for readability and neatness. The title of a page, set with the <code>\title</code> command, uses the same case as the other titles on that page. | |||
''''' | |||
A title names the topic. A reader who scans the table of contents should be able to predict what the section holds. Two checks help with a close call: | |||
* Prediction: a reader can say what the section holds without reading it. | |||
* Stability: the title is still correct after the status of the work changes. | |||
A title is not a finding, a verdict, or a rhetorical question, and it carries no final period or colon. For example, ''Signals and slots'' names a topic, but ''Why signals are better than callbacks'' makes a claim. | |||
=== Task-based titles === | === Task-based titles === | ||
| Line 106: | Line 85: | ||
* For sections about performing tasks, use verbs in progressive form: ''Building...'', ''Using...'', ''Creating...'', ''Connecting...'', and so on. | * For sections about performing tasks, use verbs in progressive form: ''Building...'', ''Using...'', ''Creating...'', ''Connecting...'', and so on. | ||
* For sections about a sub-system or a description, use nouns: ''Coordinate systems'', | * For sections about a sub-system or a description, use nouns: ''Coordinate systems'', ''Chart types'', ''Dynamic properties'', and so on. | ||
=== Linking issues with section titles === | === Linking issues with section titles === | ||
'''''Choose unique titles to avoid linking problems.''''' | '''''Choose unique titles to avoid linking problems.''''' | ||
QDoc uses section titles as link targets, and a common issue is mis-linking to unwanted sections'''''.''''' This issue is because QDoc links to titles that already exist. | QDoc uses section titles as link targets, and a common issue is mis-linking to unwanted sections'''''.''''' This issue is because QDoc links to titles that already exist. | ||
Search for already existing titles, run QDoc, and check the HTML output for missing or misdirected links. | Search for already existing titles, run QDoc, and check the HTML output for missing or misdirected links. | ||
== | See rule R12 and rule G31 in the [[Qt Documentation Rules#Grammar|Grammar]] and [[Qt Documentation Rules#Judgment rules|Judgment rules]] sections. | ||
== Paragraphs and sections == | |||
'''''Say the point first, then stop.''''' | |||
A paragraph makes one point and states it in its first sentence. This sentence is the '''topic sentence'''. It is a plain statement of about 14 words, and never more than 30. The sentences after it give a reason, a condition, an example, or an exception. | |||
Keep paragraphs to one to three sentences. Split a paragraph when it starts a second idea, and always when it passes about 100 words. End on the last supporting sentence, with no closing sentence that restates the point. | |||
Introduce every list and table with one sentence that says what it shows. Keep a list to between two and seven items. | |||
{| class="wikitable" | |||
! Incorrect !! Correct | |||
|- | |||
| This section looks at how the cache behaves. The answer may surprise you. || The cache stores each result until the model changes. | |||
|} | |||
Put one idea in each section, in the order what, why, and how. A section that needs a second idea becomes two sections. | |||
See rule G34 in [[Qt Documentation Rules#Judgment rules|Judgment rules]]. | |||
== Writing API documentation with QDoc == | |||
Qt APIs are documented in the sources, and '''QDoc''' generates the HTML for the doc.qt.io site and an offline version for Qt Creator. These QDoc guidelines complement the [https://doc.qt.io/qt-6/qdoc-index.html QDoc Manual] | |||
'''C++ and QML documentation follow a similar style''', but there are differences. | |||
Visit the following pages to document APIs: | |||
* [[C++ Documentation Style]]: for C++ classes, functions, and properties | |||
* [[QML Documentation Style]]: for QML types, properties, and signals | |||
General syntax guidelines are on these pages: | |||
* [[QDoc Linking Guidelines]] | |||
* [[QDoc Project Templates]] | |||
The first thing to write for a class or a QML type is the '''brief''': the one-sentence summary that the <code>\brief</code> command sets. QDoc shows it in lists of types and in the page description, and it ends with a period. | |||
See the API markup rules in [[Qt Documentation Rules#Tool-checkable rules|Tool-checkable rules]]. | |||
== Notes, warnings, and markup == | |||
'''''Only noteworthy statements belong in a \note.''''' | '''''Only noteworthy statements belong in a \note.''''' | ||
Use them sparingly but be aware of their intended use and consequences. | QDoc has a '''\note''' command that creates a stylized '''''Note:''''' in the documentation. Similarly, '''\warning''' creates a '''''Warning:'''''. | ||
Use them sparingly but be aware of their intended use and consequences. | |||
* Notes and warnings break the flow of the paragraph or section, creating an aside or detour from the usual topic | * Notes and warnings break the flow of the paragraph or section, creating an aside or detour from the usual topic | ||
* '''''\note is only for short statements'''.'' See [https://doc.qt.io/qt-6/11-qdoc-commands-specialcontent.html#note \note command] in the QDoc manual | * '''''\note is only for short statements'''.'' See [https://doc.qt.io/qt-6/11-qdoc-commands-specialcontent.html#note \note command] in the QDoc manual | ||
* Reserve '''''\warning''''' for critical information that | * Reserve '''''\warning''''' for critical information that leads to serious consequences | ||
Think of the hierarchy of information. When | |||
Think of the hierarchy of information. When several statements are important, put only the most important one in a \note. | |||
'''''The general | '''''The general hierarchy of information, in order of highlighted importance, is:''''' | ||
'''''Statement'' → ''Advice'' → ''Note'' → ''Warning''''' | '''''Statement'' → ''Advice'' → ''Note'' → ''Warning''''' | ||
Integrate the other statements into the paragraph. A one-line paragraph on its own is better than the overuse of notes. | |||
Use a list if there are several notes after each other. For example, add | Use a list if there are several notes after each other. For example, add '''''\section1 Additional notes''''' at the end of your page to collect the notes. | ||
For example: | For example: <blockquote>'''Additional notes''' | ||
* Statement A | * Statement A | ||
* Statement B | * Statement B | ||
* Statement C | * Statement C | ||
</blockquote> | </blockquote> | ||
'''''Mark up text or code to indicate to the reader that the text is special...'''such as code or text visible to the application user.'' | |||
These are the common markup commands in Qt documentation: | |||
* [https://doc.qt.io/qt-6/04-qdoc-commands-textmarkup.html#c-code-font \c] command for marking code such as default values or output. Rendered in monospace font. | |||
* [https://doc.qt.io/qt-6/04-qdoc-commands-textmarkup.html#uicontrol \uicontrol] command for UI text visible to application users. Rendered in bold. | |||
See [https://doc.qt.io/qt-6/04-qdoc-commands-textmarkup.html Text Markup] for other markup commands | |||
The comment below goes above the function in a C++ source file. The <code>\fn</code> command names the function, and <code>\sa</code> adds a see-also link. The comment generates the documentation for [https://doc.qt.io/qt-6/qwidget.html#focusNextChild QWidget::focusNextChild()]:<syntaxhighlight lang="c++"> | |||
/*! | |||
\fn bool QWidget::focusNextChild() | |||
== | Finds a new widget to give the keyboard focus to, as appropriate | ||
for \uicontrol Tab, and returns \c true if it can find a new widget, or | |||
false if it can't. | |||
\sa focusPreviousChild() | |||
*/ | |||
</syntaxhighlight> | |||
See the markup rules in [[Qt Documentation Rules#Judgment rules|Judgment rules]]. | |||
== Examples, snippets, and images == | |||
Qt Examples are an important part of the Qt Framework. They show how the framework is to be used and inspire developers about possibilities with Qt. These pages help with creating, documenting, and how to contribute examples into the Qt repositories. | Qt Examples are an important part of the Qt Framework. They show how the framework is to be used and inspire developers about possibilities with Qt. These pages help with creating, documenting, and how to contribute examples into the Qt repositories. | ||
* [[Qt Examples Guidelines]] - do's and don'ts for examples | * [[Qt Examples Guidelines]] - do's and don'ts for examples | ||
* [[Writing Example Documentation and Tutorials]] - writing example documentation and tutorials | |||
* [[Writing Example Documentation and Tutorials]] | |||
* [[Contributing Examples to Qt]] - configuring an example for integration into the Qt repositories | * [[Contributing Examples to Qt]] - configuring an example for integration into the Qt repositories | ||
* [[Qt Examples in Qt Creator]] - ensuring that the example works within Qt Creator | * [[Qt Examples in Qt Creator]] - ensuring that the example works within Qt Creator | ||
'''''Make sure your snippet compiles and runs.''''' | |||
It is best to include code snippets using the '''\snippet <filename>''' command. Qt documentation aims to include compilable and usable code. If the code is inside a source file, then \snippet can quote it from overviews, tutorials, and API documentation. | |||
Read the ''QDoc Manual'' about the other commands relating to including sources in documentation. See [https://doc.qt.io/qt-6/07-0-qdoc-commands-includingexternalcode.html Including External Code] | |||
The previous guideline about '''''using''''' '''''\code''''' '''''and''' '''\endcode''' '''is no longer preferred''''', though it is still possible to use these commands. | |||
For quoting input or output text (from the terminal, for example), use the various quotation commands. See [https://doc.qt.io/qt-6/06-qdoc-commands-includecodeinline.html Including Code Inline] | |||
The requirements for images in Qt documentation are outlined in [https://contribute.qt-project.org/quips/21 QUIP-21], ''Using images in Qt documentation''. | |||
You should add an alternate text (alt text) to images. The alt text fills the HTML's alt attribute for screen readers and accessibility tools. Start the text capitalized and do not end with a period.<syntaxhighlight lang="c"> | You should add an alternate text (alt text) to images. The alt text fills the HTML's alt attribute for screen readers and accessibility tools. Start the text capitalized and do not end with a period.<syntaxhighlight lang="c"> | ||
\image imagename.webp {A | \image imagename.webp {A window with a blue background} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
See the alt text rules in [[Qt Documentation Rules#Tool-checkable rules|Tool-checkable rules]] and [[Qt Documentation Rules#Judgment rules|Judgment rules]]. | |||
== Checking your documentation == | |||
Check your text before you push a change to Gerrit, the code review system of the Qt Project. These checks catch most problems early and make integration smoother. | |||
'''Vale''' is a linter, a program that reads text and reports places that break a rule. It detects improper use of language and can make suggestions in-place. Vale has a command-line interface and is also available for Qt Creator and VS Code. For more information about Vale, visit [[Setting Up Vale]]. | |||
[ | Run QDoc on your change and read its warnings. The [https://doc.qt.io/qt-6/qdoc-index.html QDoc Manual] explains how to run it. Then follow the checks in the list, starting with the regression test for a small edit: | ||
* [[Checklist for Adding Documentation for a New Module]] | |||
* [[Qt_Documentation_Structure | Documentation Structure]] - a map of the directory structure of a repository or module | |||
* [[QDoc Regression Testing]] - test the content before you push a patch to codereview.qt-project.org | |||
An assisted review of documentation changes is planned. A pointer to it is added here when it is public. | |||
See the checking rules in [[Qt Documentation Rules#Enforcement levels|Enforcement levels]]. | |||
== See also == | == See also == | ||
* [[ | * [[Qt Documentation Rules]]: the rules, each with a stable ID. Read this page next. | ||
* [https://contribute.qt-project.org/quips/25 QUIP 25]: Documentation writing style | |||
* [https://learn.microsoft.com/en-us/style-guide/welcome/ Microsoft Writing Style Guide] | |||
Latest revision as of 12:14, 23 November 2026
The Qt Writing Guidelines contains information about writing Qt documentation in a consistent way. Though there are exceptions, maintain the consistency level outlined in the guidelines or the existing Qt documentation.
This guideline is maintained by the Qt Documentation Team, with members across the different Qt Group sites. Visit their page at: Contributing to Qt Documentation
Purpose and scope
This page is the short entry point for anyone who writes Qt documentation. It covers the decisions a writer makes first, and each section ends with a link to the detailed rules.
The Qt documentation is written in a source format that a tool called QDoc reads. QDoc turns documentation comments in C++ and QML source files, and separate .qdoc files, into the HTML pages on doc.qt.io. QML is the declarative language that Qt Quick applications use. A command that starts with a backslash, such as \brief, tells QDoc what a piece of text is.
To make your first documentation change, follow these steps in order: find the source file that holds the text, edit it, run QDoc and Vale on it, and push the change to Gerrit. The sections Checking your documentation and Contributing to Qt Documentation cover the last steps. Rules have IDs, such as R12 or G34. The letter R marks a rule that a tool checks using regular expressions, and G marks a rule that needs a person's judgment.
Start with the three habits that fix most problems: write in active voice, put the main point of each paragraph first, and write section titles in sentence case. The example shows the first habit.
| Incorrect | Correct |
|---|---|
| Events are ignored by the item when it is disabled. | The item ignores events when it is disabled. |
When two sources disagree, follow the one that ranks higher: this page first, then QUIP 25 (a Qt Project proposal document, here on documentation writing style), then the C++ Documentation Style and QML Documentation Style pages, then the Microsoft Writing Style Guide. The QDoc Manual is the authority for command syntax, not for style.
The full list of rules, each with a stable ID, is on the Qt Documentation Rules page. See Sources for the ranking of sources.
Choosing the content type
A content type is the kind of page or text that you write. The type decides which rules apply, because an API reference entry and a tutorial step read differently.
To choose the type, look at the QDoc command that opens the text. The main groups are:
- API reference for C++ and QML, opened by commands such as
\class,\fn,\qmltype, and\qmlproperty - Module pages, overviews, and concept pages, opened by
\module,\qmlmodule, or\page - Examples, tutorials, and getting-started pages
- Platform, deployment, porting, and tools pages
- Commit messages and reports
The content-type table on the Rules page is the source of truth. It lists the detection pattern and the writing register of each type, and this page holds no second copy. A register is the way a type sounds: its person, tense, and sentence length. When a page fits no type, treat it as an overview page.
See the content type rules in Content types.
Language style
Say the text out loud. If it sounds weird, then it is weird...and may need editing.
Qt uses the Microsoft Writing Style Guide in the Qt documentation. Use clear and direct language in American English. We write to a diverse audience and we need to communicate Qt topics in an approachable and understandable manner.
Here are some specifics for Qt:
- Use active voice, not passive. Passive does not make a sentence formal, but unnecessarily weakens the sentence. See Verbs
- Use the pronoun you to address the reader when appropriate. See Nouns and Pronouns.
- Use because instead of since or as. See Use simple words, concise sentences.
- Use a serial comma, also known as the Oxford comma. See Commas.
- Use the correct spelling and case for Qt Products. See Qt Terms and Concepts.
- Be consistent with forming lists. The
\listcommand starts a list, each item starts with\li, and\endlistcloses it. Use the same tone or mode and be consistent about ending with periods. - Use US spelling and avoid Latin abbreviations. See Use US spelling and avoid non-English words. For example, write that is instead of i.e., and for example instead of e.g..
The Substitutions and terminology section of the Rules page holds the full table of Latin terms and their replacements.
Translated documentation
New in Qt 6.8, the Qt Reference Documentation is available in translated formats. Choose words that are simpler to translate or interpret. If the text is too complicated, then it may be poorly translated by translation tools.
See the language rules in Tool-checkable rules and Judgment rules.
Titles and headings
Consistency is key...write sections in sentence-case, but maintain consistency with existing pages.
Write a section title as the argument to a \section1 or \section2 command. The \section1 command starts a top-level section of a page, and \section2 starts a subsection inside it.
Write section titles in sentence-case as indicated by the Microsoft Writing Style Guide. See Formatting titles.
The previous guideline about using title-case is no longer valid, but maintain consistency within the page for readability and neatness. The title of a page, set with the \title command, uses the same case as the other titles on that page.
A title names the topic. A reader who scans the table of contents should be able to predict what the section holds. Two checks help with a close call:
- Prediction: a reader can say what the section holds without reading it.
- Stability: the title is still correct after the status of the work changes.
A title is not a finding, a verdict, or a rhetorical question, and it carries no final period or colon. For example, Signals and slots names a topic, but Why signals are better than callbacks makes a claim.
Task-based titles
In Qt, the section title could be about performing tasks or a description of a sub-system.
Here are some suggestions:
- For sections about performing tasks, use verbs in progressive form: Building..., Using..., Creating..., Connecting..., and so on.
- For sections about a sub-system or a description, use nouns: Coordinate systems, Chart types, Dynamic properties, and so on.
Linking issues with section titles
Choose unique titles to avoid linking problems.
QDoc uses section titles as link targets, and a common issue is mis-linking to unwanted sections. This issue is because QDoc links to titles that already exist.
Search for already existing titles, run QDoc, and check the HTML output for missing or misdirected links.
See rule R12 and rule G31 in the Grammar and Judgment rules sections.
Paragraphs and sections
Say the point first, then stop.
A paragraph makes one point and states it in its first sentence. This sentence is the topic sentence. It is a plain statement of about 14 words, and never more than 30. The sentences after it give a reason, a condition, an example, or an exception.
Keep paragraphs to one to three sentences. Split a paragraph when it starts a second idea, and always when it passes about 100 words. End on the last supporting sentence, with no closing sentence that restates the point.
Introduce every list and table with one sentence that says what it shows. Keep a list to between two and seven items.
| Incorrect | Correct |
|---|---|
| This section looks at how the cache behaves. The answer may surprise you. | The cache stores each result until the model changes. |
Put one idea in each section, in the order what, why, and how. A section that needs a second idea becomes two sections.
See rule G34 in Judgment rules.
Writing API documentation with QDoc
Qt APIs are documented in the sources, and QDoc generates the HTML for the doc.qt.io site and an offline version for Qt Creator. These QDoc guidelines complement the QDoc Manual
C++ and QML documentation follow a similar style, but there are differences.
Visit the following pages to document APIs:
- C++ Documentation Style: for C++ classes, functions, and properties
- QML Documentation Style: for QML types, properties, and signals
General syntax guidelines are on these pages:
The first thing to write for a class or a QML type is the brief: the one-sentence summary that the \brief command sets. QDoc shows it in lists of types and in the page description, and it ends with a period.
See the API markup rules in Tool-checkable rules.
Notes, warnings, and markup
Only noteworthy statements belong in a \note.
QDoc has a \note command that creates a stylized Note: in the documentation. Similarly, \warning creates a Warning:.
Use them sparingly but be aware of their intended use and consequences.
- Notes and warnings break the flow of the paragraph or section, creating an aside or detour from the usual topic
- \note is only for short statements. See \note command in the QDoc manual
- Reserve \warning for critical information that leads to serious consequences
Think of the hierarchy of information. When several statements are important, put only the most important one in a \note.
The general hierarchy of information, in order of highlighted importance, is:
Statement → Advice → Note → Warning
Integrate the other statements into the paragraph. A one-line paragraph on its own is better than the overuse of notes.
Use a list if there are several notes after each other. For example, add \section1 Additional notes at the end of your page to collect the notes.
For example:
Additional notes
- Statement A
- Statement B
- Statement C
Mark up text or code to indicate to the reader that the text is special...such as code or text visible to the application user.
These are the common markup commands in Qt documentation:
- \c command for marking code such as default values or output. Rendered in monospace font.
- \uicontrol command for UI text visible to application users. Rendered in bold.
See Text Markup for other markup commands
The comment below goes above the function in a C++ source file. The \fn command names the function, and \sa adds a see-also link. The comment generates the documentation for QWidget::focusNextChild():
/*!
\fn bool QWidget::focusNextChild()
Finds a new widget to give the keyboard focus to, as appropriate
for \uicontrol Tab, and returns \c true if it can find a new widget, or
false if it can't.
\sa focusPreviousChild()
*/
See the markup rules in Judgment rules.
Examples, snippets, and images
Qt Examples are an important part of the Qt Framework. They show how the framework is to be used and inspire developers about possibilities with Qt. These pages help with creating, documenting, and how to contribute examples into the Qt repositories.
- Qt Examples Guidelines - do's and don'ts for examples
- Writing Example Documentation and Tutorials - writing example documentation and tutorials
- Contributing Examples to Qt - configuring an example for integration into the Qt repositories
- Qt Examples in Qt Creator - ensuring that the example works within Qt Creator
Make sure your snippet compiles and runs.
It is best to include code snippets using the \snippet <filename> command. Qt documentation aims to include compilable and usable code. If the code is inside a source file, then \snippet can quote it from overviews, tutorials, and API documentation.
Read the QDoc Manual about the other commands relating to including sources in documentation. See Including External Code
The previous guideline about using \code and \endcode is no longer preferred, though it is still possible to use these commands.
For quoting input or output text (from the terminal, for example), use the various quotation commands. See Including Code Inline
The requirements for images in Qt documentation are outlined in QUIP-21, Using images in Qt documentation.
You should add an alternate text (alt text) to images. The alt text fills the HTML's alt attribute for screen readers and accessibility tools. Start the text capitalized and do not end with a period.
\image imagename.webp {A window with a blue background}
See the alt text rules in Tool-checkable rules and Judgment rules.
Checking your documentation
Check your text before you push a change to Gerrit, the code review system of the Qt Project. These checks catch most problems early and make integration smoother.
Vale is a linter, a program that reads text and reports places that break a rule. It detects improper use of language and can make suggestions in-place. Vale has a command-line interface and is also available for Qt Creator and VS Code. For more information about Vale, visit Setting Up Vale.
Run QDoc on your change and read its warnings. The QDoc Manual explains how to run it. Then follow the checks in the list, starting with the regression test for a small edit:
- Checklist for Adding Documentation for a New Module
- Documentation Structure - a map of the directory structure of a repository or module
- QDoc Regression Testing - test the content before you push a patch to codereview.qt-project.org
An assisted review of documentation changes is planned. A pointer to it is added here when it is public.
See the checking rules in Enforcement levels.
See also
- Qt Documentation Rules: the rules, each with a stable ID. Read this page next.
- QUIP 25: Documentation writing style
- Microsoft Writing Style Guide