Replace 'code' directives with 'code-block' directives.

The `code` directive highlights all sources as GDScript. Other languages are
highlighted incorrectly at the moment, even if `.. code:: [language]` is
specified.

It does, however, work with the `code-block` directive. The reason seems to be
that this directive is Sphinx specific.
This commit is contained in:
asynts
2020-01-12 20:08:42 +01:00
parent 3dede275f4
commit 53f878bdaf
14 changed files with 84 additions and 85 deletions

View File

@@ -19,7 +19,7 @@ To bind to an external library, set up a module directory similar to the Summato
Next, you will create a header file with a simple TTS class:
.. code:: cpp
.. code-block:: cpp
/* tts.h */
@@ -44,7 +44,7 @@ Next, you will create a header file with a simple TTS class:
And then you'll add the cpp file.
.. code:: cpp
.. code-block:: cpp
/* tts.cpp */
@@ -77,7 +77,7 @@ need to be created:
With the following contents:
.. code:: cpp
.. code-block:: cpp
/* register_types.h */
@@ -85,7 +85,7 @@ With the following contents:
void unregister_tts_types();
/* yes, the word in the middle must be the same as the module folder name */
.. code:: cpp
.. code-block:: cpp
/* register_types.cpp */
@@ -105,7 +105,7 @@ With the following contents:
Next, you need to create a ``SCsub`` file so the build system compiles
this module:
.. code:: python
.. code-block:: python
# SCsub
@@ -157,7 +157,7 @@ can link to them instead by adding them as submodules (from within the modules/t
To add include directories for the compiler to look at you can append it to the
environment's paths:
.. code:: python
.. code-block:: python
env_tts.Append(CPPPATH=["speech_tools/include", "festival/src/include"]) # this is a path relative to /modules/tts/
# http://www.cstr.ed.ac.uk/projects/festival/manual/festival_28.html#SEC132 <-- Festival library documentation
@@ -169,7 +169,7 @@ If you want to add custom compiler flags when building your module, you need to
`env` first, so it won't add those flags to whole Godot build (which can cause errors).
Example `SCsub` with custom flags:
.. code:: python
.. code-block:: python
# SCsub

View File

@@ -107,18 +107,18 @@ For dynamic memory, the PoolVector<> template is provided. PoolVector is a
standard vector class, and is very similar to vector in the C++ standard library.
To create a PoolVector buffer, use this:
.. code:: cpp
.. code-block:: cpp
PoolVector<int> data;
PoolVector can be accessed using the [] operator and a few helpers exist for this:
.. code:: cpp
.. code-block:: cpp
PoolVector<int>::Read r = data.read()
int someint = r[4]
.. code:: cpp
.. code-block:: cpp
PoolVector<int>::Write w = data.write()
w[4] = 22;
@@ -149,7 +149,7 @@ in C++ are often inlined and make the binary size much fatter, both in
debug symbols and code. List, Set and Map can be iterated using
pointers, like this:
.. code:: cpp
.. code-block:: cpp
for(List<int>::Element *E=somelist.front();E;E=E->next()) {
print_line(E->get()); // print the element

View File

@@ -45,7 +45,7 @@ ResourceLoader. ResourceLoader loads once and references the same
object regardless how many times ``load`` is called on a specific resource.
Therefore, playback state must be self contained in AudioStreamPlayback.
.. code:: cpp
.. code-block:: cpp
/* audiostream_mytone.h */
@@ -76,7 +76,7 @@ Therefore, playback state must be self contained in AudioStreamPlayback.
static void _bind_methods();
};
.. code:: cpp
.. code-block:: cpp
/* audiostream_mytone.cpp */
@@ -126,7 +126,7 @@ AudioStreamPlayer uses ``mix`` callback to obtain PCM data. The callback must ma
Since AudioStreamPlayback is controlled by the audio thread, i/o and dynamic memory allocation are forbidden.
.. code:: cpp
.. code-block:: cpp
/* audiostreamplayer_mytone.h */
@@ -164,7 +164,7 @@ Since AudioStreamPlayback is controlled by the audio thread, i/o and dynamic mem
~AudioStreamPlaybackMyTone();
};
.. code:: cpp
.. code-block:: cpp
/* audiostreamplayer_mytone.cpp */
@@ -238,7 +238,7 @@ Godot provides cubic interpolation for audio resampling.
Instead of overloading ``mix``, AudioStreamPlaybackResampled uses ``_mix_internal`` to
query AudioFrames and ``get_stream_sampling_rate`` to query current mix rate.
.. code:: cpp
.. code-block:: cpp
#include "core/reference.h"
#include "core/resource.h"
@@ -279,7 +279,7 @@ query AudioFrames and ``get_stream_sampling_rate`` to query current mix rate.
~AudioStreamPlaybackResampledMyTone();
};
.. code:: cpp
.. code-block:: cpp
#include "mytone_audiostream_resampled.h"

View File

@@ -38,7 +38,7 @@ Creating a Godot server
At minimum, a server must have a static instance, a sleep timer, a thread loop,
an initialization state and a cleanup procedure.
.. code:: cpp
.. code-block:: cpp
#ifndef HILBERT_HOTEL_H
#define HILBERT_HOTEL_H
@@ -92,7 +92,7 @@ an initialization state and a cleanup procedure.
#endif
.. code:: cpp
.. code-block:: cpp
#include "hilbert_hotel.h"
@@ -236,7 +236,7 @@ an initialization state and a cleanup procedure.
singleton = this;
}
.. code:: cpp
.. code-block:: cpp
/* prime_225.h */
@@ -278,7 +278,7 @@ Godot servers implement a mediator pattern. All data types inherit ``RID_Data``.
RID_Owner maintains a list of RIDs. In practice, RIDs are similar to writing
object-oriented C code.
.. code:: cpp
.. code-block:: cpp
class InfiniteBus : public RID_Data {
RID self;
@@ -332,7 +332,7 @@ class must be created to reference the proper Godot server.
In ``register_server_types()``, ``Engine::get_singleton()->add_singleton``
is used to register the dummy class in GDScript.
.. code:: cpp
.. code-block:: cpp
/* register_types.cpp */
@@ -365,7 +365,7 @@ is used to register the dummy class in GDScript.
}
}
.. code:: cpp
.. code-block:: cpp
/* register_types.h */
@@ -380,7 +380,7 @@ Bind methods
The dummy class binds singleton methods to GDScript. In most cases, the dummy class methods wraps around.
.. code:: cpp
.. code-block:: cpp
Variant _HilbertHotel::get_bus_info(RID id) {
return HilbertHotel::get_singleton()->get_bus_info(id);
@@ -390,13 +390,13 @@ Binding Signals
It is possible to emit signals to GDScript by calling the GDScript dummy object.
.. code:: cpp
.. code-block:: cpp
void HilbertHotel::_emit_occupy_room(uint64_t room, RID rid) {
_HilbertHotel::get_singleton()->_occupy_room(room, rid);
}
.. code:: cpp
.. code-block:: cpp
class _HilbertHotel : public Object {
GDCLASS(_HilbertHotel, Object);
@@ -423,7 +423,7 @@ It is possible to emit signals to GDScript by calling the GDScript dummy object.
#endif
.. code:: cpp
.. code-block:: cpp
_HilbertHotel *_HilbertHotel::singleton = NULL;
_HilbertHotel *_HilbertHotel::get_singleton() { return singleton; }

View File

@@ -54,7 +54,7 @@ located):
Inside we will create a simple summator class:
.. code:: cpp
.. code-block:: cpp
/* summator.h */
@@ -83,7 +83,7 @@ Inside we will create a simple summator class:
And then the cpp file.
.. code:: cpp
.. code-block:: cpp
/* summator.cpp */
@@ -121,7 +121,7 @@ need to be created:
With the following contents:
.. code:: cpp
.. code-block:: cpp
/* register_types.h */
@@ -129,7 +129,7 @@ With the following contents:
void unregister_summator_types();
/* yes, the word in the middle must be the same as the module folder name */
.. code:: cpp
.. code-block:: cpp
/* register_types.cpp */
@@ -149,7 +149,7 @@ With the following contents:
Next, we need to create a ``SCsub`` file so the build system compiles
this module:
.. code:: python
.. code-block:: python
# SCsub
@@ -160,7 +160,7 @@ this module:
With multiple sources, you can also add each file individually to a Python
string list:
.. code:: python
.. code-block:: python
src_list = ["summator.cpp", "other.cpp", "etc.cpp"]
env.add_source_files(env.modules_sources, src_list)
@@ -172,7 +172,7 @@ with Godot by default for examples.
To add include directories for the compiler to look at you can append it to the
environment's paths:
.. code:: python
.. code-block:: python
env.Append(CPPPATH=["mylib/include"]) # this is a relative path
env.Append(CPPPATH=["#myotherlib/include"]) # this is an 'absolute' path
@@ -181,7 +181,7 @@ If you want to add custom compiler flags when building your module, you need to
`env` first, so it won't add those flags to whole Godot build (which can cause errors).
Example `SCsub` with custom flags:
.. code:: python
.. code-block:: python
# SCsub
@@ -195,7 +195,7 @@ Example `SCsub` with custom flags:
And finally, the configuration file for the module, this is a simple
python script that must be named ``config.py``:
.. code:: python
.. code-block:: python
# config.py
@@ -266,7 +266,7 @@ long and costly part.
The solution to avoid such a cost is to build our own module as a shared
library that will be dynamically loaded when starting our game's binary.
.. code:: python
.. code-block:: python
# SCsub
@@ -314,7 +314,7 @@ module as shared library (for development) or as a part of the Godot binary
(for release). To do that we can define a custom flag to be passed to SCons
using the `ARGUMENT` command:
.. code:: python
.. code-block:: python
# SCsub
@@ -367,7 +367,7 @@ There are several steps in order to setup custom docs for the module:
2. Append the following code snippet to ``config.py``:
.. code:: python
.. code-block:: python
def get_doc_classes():
return [
@@ -438,7 +438,7 @@ Once you've created your icon(s), proceed with the following steps:
If you'd like to store your icons somewhere else within your module,
add the following code snippet to ``config.py`` to override the default path:
.. code:: python
.. code-block:: python
def get_icons_path():
return "path/to/icons"

View File

@@ -55,7 +55,7 @@ resources with the ``load`` function. To load a resource, ``load`` must
read and handle data serialization.
.. code:: cpp
.. code-block:: cpp
#ifndef MY_JSON_LOADER_H
#define MY_JSON_LOADER_H
@@ -74,7 +74,7 @@ read and handle data serialization.
};
#endif // MY_JSON_LOADER_H
.. code:: cpp
.. code-block:: cpp
#include "my_json_loader.h"
#include "my_json.h"
@@ -115,7 +115,7 @@ understand additional binary formats such as machine learning models.
Here is an example of how to create a custom datatype
.. code:: cpp
.. code-block:: cpp
#ifndef MY_JSON_H
#define MY_JSON_H
@@ -179,7 +179,7 @@ Therefore, Godot call translations are required.
For example, here is the code for translating ``FileAccess``
calls into ``std::istream``.
.. code:: cpp
.. code-block:: cpp
#include <istream>
#include <streambuf>
@@ -223,7 +223,7 @@ Godot registers ``ResourcesFormatLoader`` with a ``ResourceLoader``
handler. The handler selects the proper loader automatically
when ``load`` is called.
.. code:: cpp
.. code-block:: cpp
/* register_types.cpp */
#include "register_types.h"
@@ -251,7 +251,6 @@ References
Loading it on GDScript
----------------------
.. code-block:: json
{

View File

@@ -11,7 +11,7 @@ inherit directly or indirectly from it. Objects provide reflection and
editable properties, and declaring them is a matter of using a single
macro like this.
.. code:: cpp
.. code-block:: cpp
class CustomObject : public Object {
@@ -20,7 +20,7 @@ macro like this.
This makes Objects gain a lot of functionality, like for example
.. code:: cpp
.. code-block:: cpp
obj = memnew(CustomObject);
print_line("Object class: ", obj->get_class()); // print object class
@@ -41,7 +41,7 @@ their methods properties and integer constants.
Classes are registered by calling:
.. code:: cpp
.. code-block:: cpp
ClassDB::register_class<MyCustomClass>()
@@ -50,7 +50,7 @@ creating them again when deserializing.
Registering as virtual is the same but it can't be instanced.
.. code:: cpp
.. code-block:: cpp
ClassDB::register_virtual_class<MyCustomClass>()
@@ -64,13 +64,13 @@ virtual automatically.
Inside ``_bind_methods``, there are a couple of things that can be done.
Registering functions is one:
.. code:: cpp
.. code-block:: cpp
ClassDB::register_method(D_METHOD("methodname", "arg1name", "arg2name"), &MyCustomMethod);
Default values for arguments can be passed in reverse order:
.. code:: cpp
.. code-block:: cpp
ClassDB::register_method(D_METHOD("methodname", "arg1name", "arg2name"), &MyCustomType::method, DEFVAL(-1)); // default value for arg2name
@@ -95,7 +95,7 @@ Constants
Classes often have enums such as:
.. code:: cpp
.. code-block:: cpp
enum SomeMode {
MODE_FIRST,
@@ -105,13 +105,13 @@ Classes often have enums such as:
For these to work when binding to methods, the enum must be declared
convertible to int, for this a macro is provided:
.. code:: cpp
.. code-block:: cpp
VARIANT_ENUM_CAST(MyClass::SomeMode); // now functions that take SomeMode can be bound.
The constants can also be bound inside ``_bind_methods``, by using:
.. code:: cpp
.. code-block:: cpp
BIND_CONSTANT(MODE_FIRST);
BIND_CONSTANT(MODE_SECOND);
@@ -127,13 +127,13 @@ Objects export properties, properties are useful for the following:
Properties are usually defined by the PropertyInfo() class. Usually
constructed as:
.. code:: cpp
.. code-block:: cpp
PropertyInfo(type, name, hint, hint_string, usage_flags)
For example:
.. code:: cpp
.. code-block:: cpp
PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_RANGE, "0,49,1", PROPERTY_USAGE_EDITOR)
@@ -143,7 +143,7 @@ from 0 to 49 in steps of 1 (integers). It is only usable for the editor
Another example:
.. code:: cpp
.. code-block:: cpp
PropertyInfo(Variant::STRING, "modes", PROPERTY_HINT_ENUM, "Enabled,Disabled,Turbo")
@@ -163,7 +163,7 @@ impossible unless using operator [].
From ``_bind_methods()``, properties can be created and bound as long as
set/get functions exist. Example:
.. code:: cpp
.. code-block:: cpp
ADD_PROPERTY(PropertyInfo(Variant::INT, "amount"), "set_amount", "get_amount")
@@ -180,7 +180,7 @@ they are NOT virtual, DO NOT make them virtual, they are called for
every override and the previous ones are not invalidated (multilevel
call).
.. code:: cpp
.. code-block:: cpp
void _get_property_info(List<PropertyInfo> *r_props); // return list of properties
bool _get(const StringName &p_property, Variant &r_value) const; // return true if property was found
@@ -195,7 +195,7 @@ Dynamic casting
Godot provides dynamic casting between Object-derived classes, for
example:
.. code:: cpp
.. code-block:: cpp
void somefunc(Object *some_obj) {
@@ -213,7 +213,7 @@ Signals
Objects can have a set of signals defined (similar to Delegates in other
languages). Connecting to them is rather easy:
.. code:: cpp
.. code-block:: cpp
obj->connect(<signal>, target_instance, target_method)
// for example:
@@ -225,7 +225,7 @@ The method ``_node_entered_tree`` must be registered to the class using
Adding signals to a class is done in ``_bind_methods``, using the
``ADD_SIGNAL`` macro, for example:
.. code:: cpp
.. code-block:: cpp
ADD_SIGNAL(MethodInfo("been_killed"))
@@ -236,7 +236,7 @@ References
reference count. It is the base for reference counted object types.
Declaring them must be done using Ref<> template. For example:
.. code:: cpp
.. code-block:: cpp
class MyReference: public Reference {
GDCLASS(MyReference, Reference);
@@ -273,7 +273,7 @@ Resource loading
Resources can be loaded with the ResourceLoader API, like this:
.. code:: cpp
.. code-block:: cpp
Ref<Resource> res = ResourceLoader::load("res://someresource.res")
@@ -294,7 +294,7 @@ Resource saving
Saving a resource can be done with the resource saver API:
.. code:: cpp
.. code-block:: cpp
ResourceSaver::save("res://someresource.res", instance)