Skip to content

Commit 18092b0

Browse files
authored
Merge pull request #10151 from adamscott/add-caption-filename
Add filenames as captions for code blocks
2 parents d904c1d + 44dfb3a commit 18092b0

File tree

12 files changed

+64
-77
lines changed

12 files changed

+64
-77
lines changed

contributing/development/code_style_guidelines.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ ones, the following rules should be followed:
169169
Example:
170170

171171
.. code-block:: cpp
172+
:caption: my_new_file.h
172173
173174
/**************************************************************************/
174175
/* my_new_file.h */
@@ -214,6 +215,7 @@ Example:
214215
#endif // MY_NEW_FILE_H
215216
216217
.. code-block:: cpp
218+
:caption: my_new_file.cpp
217219
218220
/**************************************************************************/
219221
/* my_new_file.cpp */

contributing/development/compiling/introduction_to_the_buildsystem.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ The default ``custom.py`` file can be created at the root of the Godot Engine
321321
source to initialize any SCons build options passed via the command line:
322322

323323
.. code-block:: python
324-
325-
# custom.py
324+
:caption: custom.py
326325
327326
optimize = "size"
328327
module_mono_enabled = "yes"
@@ -352,8 +351,7 @@ line option, both overriding the default build configuration:
352351
It's also possible to override the options conditionally:
353352

354353
.. code-block:: python
355-
356-
# custom.py
354+
:caption: custom.py
357355
358356
import version
359357

contributing/development/compiling/optimizing_for_size.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ Alternatively, you can supply a list of disabled modules by creating
226226
following:
227227

228228
.. code-block:: python
229-
230-
# custom.py
229+
:caption: custom.py
231230
232231
module_basis_universal_enabled = "no"
233232
module_bmp_enabled = "no"

contributing/development/configuring_an_ide/visual_studio_code.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Importing the project
3636
- Within the ``tasks.json`` file find the ``"tasks"`` array and add a new section to it:
3737

3838
.. code-block:: js
39+
:caption: .vscode/tasks.json
3940
4041
{
4142
"label": "build",
@@ -199,6 +200,7 @@ To fix include errors you may be having, you need to configure some settings in
199200
- The ``c_cpp_properties.json`` file should look similar to this for Windows:
200201

201202
.. code-block:: js
203+
:caption: .vscode/c_cpp_properties.json
202204
203205
{
204206
"configurations": [

contributing/development/core_and_modules/binding_to_external_libraries.rst

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ To bind to an external library, set up a module directory similar to the Summato
2020
Next, you will create a header file with a TTS class:
2121

2222
.. code-block:: cpp
23-
24-
/* tts.h */
23+
:caption: godot/modules/tts/tts.h
2524
2625
#ifndef GODOT_TTS_H
2726
#define GODOT_TTS_H
@@ -45,8 +44,7 @@ Next, you will create a header file with a TTS class:
4544
And then you'll add the cpp file.
4645

4746
.. code-block:: cpp
48-
49-
/* tts.cpp */
47+
:caption: godot/modules/tts/tts.cpp
5048
5149
#include "tts.h"
5250
@@ -82,16 +80,14 @@ need to be created:
8280
These files should contain the following:
8381

8482
.. code-block:: cpp
85-
86-
/* register_types.h */
83+
:caption: godot/modules/tts/register_types.h
8784
8885
void initialize_tts_module(ModuleInitializationLevel p_level);
8986
void uninitialize_tts_module(ModuleInitializationLevel p_level);
9087
/* yes, the word in the middle must be the same as the module folder name */
9188
9289
.. code-block:: cpp
93-
94-
/* register_types.cpp */
90+
:caption: godot/modules/tts/register_types.cpp
9591
9692
#include "register_types.h"
9793
@@ -113,8 +109,7 @@ Next, you need to create an ``SCsub`` file so the build system compiles
113109
this module:
114110

115111
.. code-block:: python
116-
117-
# SCsub
112+
:caption: godot/modules/tts/SCsub
118113
119114
Import('env')
120115
@@ -127,9 +122,9 @@ installation commands for Linux below, for reference.
127122

128123
.. code-block:: shell
129124
130-
sudo apt-get install festival festival-dev <-- Installs festival and speech_tools libraries
131-
apt-cache search festvox-* <-- Displays list of voice packages
132-
sudo apt-get install festvox-don festvox-rablpc16k festvox-kallpc16k festvox-kdlpc16k <-- Installs voices
125+
sudo apt-get install festival festival-dev # Installs festival and speech_tools libraries
126+
apt-cache search festvox-* # Displays list of voice packages
127+
sudo apt-get install festvox-don festvox-rablpc16k festvox-kallpc16k festvox-kdlpc16k # Installs voices
133128
134129
.. important::
135130
The voices that Festival uses (and any other potential external/3rd-party
@@ -165,6 +160,7 @@ To add include directories for the compiler to look at you can append it to the
165160
environment's paths:
166161

167162
.. code-block:: python
163+
:caption: godot/modules/tts/SCsub
168164
169165
# These paths are relative to /modules/tts/
170166
env_tts.Append(CPPPATH=["speech_tools/include", "festival/src/include"])
@@ -186,8 +182,7 @@ If you want to add custom compiler flags when building your module, you need to
186182
Example `SCsub` with custom flags:
187183

188184
.. code-block:: python
189-
190-
# SCsub
185+
:caption: godot/modules/tts/SCsub
191186
192187
Import('env')
193188

contributing/development/core_and_modules/custom_audiostreams.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ object regardless how many times ``load`` is called on a specific resource.
4646
Therefore, playback state must be self-contained in AudioStreamPlayback.
4747

4848
.. code-block:: cpp
49-
50-
/* audiostream_mytone.h */
49+
:caption: audiostream_mytone.h
5150
5251
#include "core/reference.h"
5352
#include "core/resource.h"
@@ -77,8 +76,7 @@ Therefore, playback state must be self-contained in AudioStreamPlayback.
7776
};
7877
7978
.. code-block:: cpp
80-
81-
/* audiostream_mytone.cpp */
79+
:caption: audiostream_mytone.cpp
8280
8381
#include "audiostream_mytone.h"
8482
@@ -127,8 +125,7 @@ AudioStreamPlayer uses ``mix`` callback to obtain PCM data. The callback must ma
127125
Since AudioStreamPlayback is controlled by the audio thread, i/o and dynamic memory allocation are forbidden.
128126

129127
.. code-block:: cpp
130-
131-
/* audiostreamplayer_mytone.h */
128+
:caption: audiostreamplayer_mytone.h
132129
133130
#include "core/reference.h"
134131
#include "core/resource.h"
@@ -165,8 +162,7 @@ Since AudioStreamPlayback is controlled by the audio thread, i/o and dynamic mem
165162
};
166163
167164
.. code-block:: cpp
168-
169-
/* audiostreamplayer_mytone.cpp */
165+
:caption: audiostreamplayer_mytone.cpp
170166
171167
#include "audiostreamplayer_mytone.h"
172168
@@ -239,6 +235,7 @@ Instead of overloading ``mix``, AudioStreamPlaybackResampled uses ``_mix_interna
239235
query AudioFrames and ``get_stream_sampling_rate`` to query current mix rate.
240236

241237
.. code-block:: cpp
238+
:caption: mytone_audiostream_resampled.h
242239
243240
#include "core/reference.h"
244241
#include "core/resource.h"
@@ -280,6 +277,7 @@ query AudioFrames and ``get_stream_sampling_rate`` to query current mix rate.
280277
};
281278
282279
.. code-block:: cpp
280+
:caption: mytone_audiostream_resampled.cpp
283281
284282
#include "mytone_audiostream_resampled.h"
285283

contributing/development/core_and_modules/custom_godot_servers.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ At minimum, a server must have a static instance, a sleep timer, a thread loop,
3939
an initialization state and a cleanup procedure.
4040

4141
.. code-block:: cpp
42+
:caption: hilbert_hotel.h
4243
4344
#ifndef HILBERT_HOTEL_H
4445
#define HILBERT_HOTEL_H
@@ -93,6 +94,7 @@ an initialization state and a cleanup procedure.
9394
#endif
9495
9596
.. code-block:: cpp
97+
:caption: hilbert_hotel.cpp
9698
9799
#include "hilbert_hotel.h"
98100
@@ -235,8 +237,7 @@ an initialization state and a cleanup procedure.
235237
}
236238
237239
.. code-block:: cpp
238-
239-
/* prime_225.h */
240+
:caption: prime_255.h
240241
241242
const uint64_t PRIME[225] = {
242243
2,3,5,7,11,13,17,19,23,
@@ -275,6 +276,7 @@ RID_Owner maintains a list of RIDs. In practice, RIDs are similar to writing
275276
object-oriented C code.
276277

277278
.. code-block:: cpp
279+
:caption: infinite_bus.h
278280
279281
class InfiniteBus : public RID_Data {
280282
RID self;
@@ -329,8 +331,14 @@ In ``register_server_types()``, ``Engine::get_singleton()->add_singleton``
329331
is used to register the dummy class in GDScript.
330332

331333
.. code-block:: cpp
334+
:caption: register_types.h
332335
333-
/* register_types.cpp */
336+
/* Yes, the word in the middle must be the same as the module folder name */
337+
void register_hilbert_hotel_types();
338+
void unregister_hilbert_hotel_types();
339+
340+
.. code-block:: cpp
341+
:caption: register_types.cpp
334342
335343
#include "register_types.h"
336344
@@ -361,14 +369,6 @@ is used to register the dummy class in GDScript.
361369
}
362370
}
363371
364-
.. code-block:: cpp
365-
366-
/* register_types.h */
367-
368-
/* Yes, the word in the middle must be the same as the module folder name */
369-
void register_hilbert_hotel_types();
370-
void unregister_hilbert_hotel_types();
371-
372372
- `servers/register_server_types.cpp <https://github.com/godotengine/godot/blob/master/servers/register_server_types.cpp>`__
373373

374374
Bind methods

contributing/development/core_and_modules/custom_modules_in_cpp.rst

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ The example module will be called "summator" (``godot/modules/summator``).
4545
Inside we will create a summator class:
4646

4747
.. code-block:: cpp
48-
49-
/* summator.h */
48+
:caption: godot/modules/summator/summator.h
5049
5150
#ifndef SUMMATOR_H
5251
#define SUMMATOR_H
@@ -74,8 +73,7 @@ Inside we will create a summator class:
7473
And then the cpp file.
7574

7675
.. code-block:: cpp
77-
78-
/* summator.cpp */
76+
:caption: godot/modules/summator/summator.cpp
7977
8078
#include "summator.h"
8179
@@ -116,8 +114,7 @@ need to be created:
116114
These files should contain the following:
117115

118116
.. code-block:: cpp
119-
120-
/* register_types.h */
117+
:caption: godot/modules/summator/register_types.h
121118
122119
#include "modules/register_module_types.h"
123120
@@ -126,8 +123,7 @@ These files should contain the following:
126123
/* yes, the word in the middle must be the same as the module folder name */
127124
128125
.. code-block:: cpp
129-
130-
/* register_types.cpp */
126+
:caption: godot/modules/summator/register_types.cpp
131127
132128
#include "register_types.h"
133129
@@ -152,6 +148,7 @@ Next, we need to create an ``SCsub`` file so the build system compiles
152148
this module:
153149

154150
.. code-block:: python
151+
:caption: godot/modules/summator/SCsub
155152
156153
# SCsub
157154
@@ -184,8 +181,7 @@ If you want to add custom compiler flags when building your module, you need to
184181
Example ``SCsub`` with custom flags:
185182

186183
.. code-block:: python
187-
188-
# SCsub
184+
:caption: godot/modules/summator/SCsub
189185
190186
Import('env')
191187
@@ -201,6 +197,7 @@ And finally, the configuration file for the module, this is a
201197
Python script that must be named ``config.py``:
202198

203199
.. code-block:: python
200+
:caption: godot/modules/summator/config.py
204201
205202
# config.py
206203
@@ -354,8 +351,7 @@ method which will be called before anything else during the
354351
We now need to add this method to ``register_types`` header and source files:
355352

356353
.. code-block:: cpp
357-
358-
/* register_types.h */
354+
:caption: godot/modules/summator/register_types.h
359355
360356
#define MODULE_SUMMATOR_HAS_PREREGISTER
361357
void preregister_summator_types();
@@ -369,8 +365,7 @@ We now need to add this method to ``register_types`` header and source files:
369365
has to be converted to uppercase as well.
370366

371367
.. code-block:: cpp
372-
373-
/* register_types.cpp */
368+
:caption: godot/modules/summator/register_types.cpp
374369
375370
#include "register_types.h"
376371
@@ -413,8 +408,7 @@ The solution to avoid such a cost is to build our own module as a shared
413408
library that will be dynamically loaded when starting our game's binary.
414409

415410
.. code-block:: python
416-
417-
# SCsub
411+
:caption: godot/modules/summator/SCsub
418412
419413
Import('env')
420414
@@ -470,8 +464,7 @@ module as shared library (for development) or as a part of the Godot binary
470464
using the ``ARGUMENT`` command:
471465

472466
.. code-block:: python
473-
474-
# SCsub
467+
:caption: godot/modules/summator/SCsub
475468
476469
Import('env')
477470
@@ -626,8 +619,8 @@ The procedure is the following:
626619
3. Write some test cases. Here's an example:
627620

628621
.. code-block:: cpp
622+
:caption: godot/modules/summator/tests/test_summator.h
629623
630-
// test_summator.h
631624
#ifndef TEST_SUMMATOR_H
632625
#define TEST_SUMMATOR_H
633626

0 commit comments

Comments
 (0)