Skip to content

Commit c493123

Browse files
authored
[TASK] Describe CGL for ReST (#486)
1 parent 5518273 commit c493123

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

Documentation/Index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ reStructuredText (reST).
103103

104104
Reference/*
105105
Reference/ReStructuredText/Index
106+
Reference/CodingGuidelines/Index
106107

107108
.. toctree::
108109
:hidden:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
:navigation-title: CGL for ReST files
2+
3+
.. include:: /Includes.rst.txt
4+
.. _cgl:
5+
6+
=============================================
7+
Coding guidelines for reStructured text files
8+
=============================================
9+
10+
In the official documentation files we try to follow the following coding
11+
guidelines:
12+
13+
* Indentation of 4 spaces, this includes
14+
`lists <https://docs.typo3.org/permalink/h2document:rest-lists>`_, directives,
15+
`Code blocks <https://docs.typo3.org/permalink/h2document:writing-rest-codeblocks-with-syntax-highlighting>`_,
16+
and other blocks that need to be indented in ReST.
17+
* Wrap lines at 80 chars where possible
18+
* We avoid abbreviations and colloquial language. When we use abbreviations
19+
they should be introduced in the same section.
20+
* Each ReST file must have a main header.
21+
* Each ReST file must include `.. include:: /Includes.rst.txt` to display
22+
global messages, for example for outdated versions.
23+
* It is highly recommended to use `:navigation-title: My Title` at the top
24+
of each file to provide a shorter title to be displayed in the menu.
25+
See `Navigation title: A page title displayed in menus <https://docs.typo3.org/permalink/h2document:navigation-title>`_.
26+
27+
.. literalinclude:: _general.rst.txt
28+
:caption: Documentation/Introduction.rst
29+
30+
.. _cgl-code:
31+
32+
Rules for code examples
33+
=======================
34+
35+
* Wrap code examples at 80 chars where possible to avoid horizontal scrolling.
36+
* Code examples longer then a few lines should go in external files to be
37+
included.
38+
* All code examples should lint. They should demonstrate best practices.
39+
Where best practices would over complicate things, mention that this is not
40+
a best practice but used for demonstration.
41+
42+
.. literalinclude:: _code.rst.txt
43+
:caption: Documentation/Installation.rst
44+
45+
.. _cgl-headlines:
46+
47+
Rules headlines
48+
===============
49+
50+
* Headlines are in sentence case.
51+
* Each headline should be possible to understand without context. This improves
52+
search results in the internal search and search engines.
53+
* Use the official order for marking headlines. The page title is overlined
54+
and underlined with `=`, headlines of level 2 are underlined with `=`,
55+
level 3 with `-` and level 4 with `~`.
56+
* Each headline should have a unique anchor so that permalinks to the headline
57+
can be generated.
58+
59+
.. literalinclude:: _headlines.rst.txt
60+
:caption: Documentation/HeaderDemo.rst
61+
62+
See `Headlines and Anchors <https://docs.typo3.org/permalink/h2document:headlines-and-sections>`_
63+
for more headline levels.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
:navigation-title: Installation
2+
3+
.. include:: /Includes.rst.txt
4+
.. _installation:
5+
6+
========================================
7+
Installation and usage of this extension
8+
========================================
9+
10+
You can install the extension like this:
11+
12+
.. code-block:: bash
13+
14+
composer install myvendor/my-extension
15+
16+
.. _config:
17+
18+
Create a configuration file
19+
===========================
20+
21+
If you want to see a more complete configuration, refer to the example below:
22+
23+
.. literalinclude:: _codesnippets/_config.yaml
24+
:caption: EXT:my_ext/Configuration/MyConfig/config.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:navigation-title: Introduction
2+
3+
.. include:: /Includes.rst.txt
4+
.. _introduction:
5+
6+
=====================
7+
Introduction to MyExt
8+
=====================
9+
10+
This extension provides a simple way to display weather data.
11+
12+
* It fetches data from an external API and processes it in a way that allows
13+
it to be cached and reused efficiently throughout the TYPO3 site.
14+
* The results are cached for performance.
15+
* You can configure the output in the backend.
16+
17+
This extension is compatible with TYPO3 v12 and above.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
:navigation-title: Headline levels
2+
3+
.. include:: /Includes.rst.txt
4+
.. _headline-levels:
5+
6+
=======================
7+
Headline levels in ReST
8+
=======================
9+
10+
This example demonstrates the correct use of headline levels in TYPO3
11+
documentation.
12+
13+
.. _headline-level-2:
14+
15+
Level 2 headline
16+
================
17+
18+
This is the first content section under the main title.
19+
20+
.. _headline-level-3:
21+
22+
Level 3 headline
23+
----------------
24+
25+
This subsection provides more detailed information.
26+
27+
.. _headline-level-4:
28+
29+
Level 4 headline
30+
~~~~~~~~~~~~~~~~
31+
32+
This is a lower-level note or detail under the level 3 headline.

0 commit comments

Comments
 (0)