Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial integration for questions & answers in relevant pages
Browse files Browse the repository at this point in the history
This just displays a link to a Q&A search right now.
It will be extended to display a list of relevant questions in the future.
Calinou committed Dec 1, 2020
1 parent 2e820ca commit 84f8a24
Showing 42 changed files with 166 additions and 4 deletions.
75 changes: 75 additions & 0 deletions _extensions/godot_questions_answers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
godot_questions_answers
~~~~~~~~~~~~~~~~~~~~~~~
Sphinx extension that adds a ``.. questions-answers:: tag1 tag2 ...`` directive.
This displays a link to view and ask questions on the Godot Questions & Answers platform.
This role should be added at the bottom of relevant pages.
:copyright: Copyright 2020 by The Godot Engine Community
:license: MIT
"""

from docutils.parsers.rst import directives, Directive
from docutils import nodes

# See <https://github.com/coldfix/sphinx-code-tabs/blob/main/sphinx_code_tabs/__init__.py>
# for setup code inspiration.

# The URL to the questions & answers website.
GODOT_QA_URL = "https://godotengine.org/qa"


class QuestionsAnswersNode(nodes.General, nodes.Element):
def __init__(self, tags):
"""
:param str tags: Tags to search for in the Q&A.
"""
super(QuestionsAnswersNode, self).__init__()
self.tags = tags[0]

@staticmethod
def visit(spht, node):
"""Append opening tags to document body list."""
spht.body.append(
spht.starttag(node, "div", "", **{"class": "questions-answers"})
)
spht.body.append(spht.starttag(node, "h2", "User questions"))
spht.body.append("</h2>")
spht.body.append(
spht.starttag(
node,
"a",
"View user questions for “<strong>%s</strong>”" % node.tags,
href="%s/search?q=%s" % (GODOT_QA_URL, node.tags),
target="_blank",
rel="noopener",
)
)
spht.body.append("</a>")

@staticmethod
def depart(spht, node):
"""Append closing tags to document body list."""
spht.body.append("</div>")
# Separate the User questions box from th Previous and Next page buttons.
spht.body.append("<hr>")


class QuestionsAnswers(Directive):
has_content = True

def run(self):
self.assert_has_content()
return [QuestionsAnswersNode(self.content)]


def setup(app):
app.add_directive("questions-answers", QuestionsAnswers)
app.add_node(
QuestionsAnswersNode,
html=(QuestionsAnswersNode.visit, QuestionsAnswersNode.depart),
)

return {
"parallel_read_safe": True,
"parallel_write_safe": True,
}
6 changes: 6 additions & 0 deletions _static/css/custom.css
Original file line number Diff line number Diff line change
@@ -1029,3 +1029,9 @@ kbd, .kbd {
.wy-menu.wy-menu-vertical::-webkit-scrollbar-thumb:active {
background-color: var(--navbar-scrollbar-active-color);
}

.questions-answers {
padding: 1rem;
margin-top: 2rem;
background-color: hsla(60, 50%, 50%, 0.125);
}
3 changes: 3 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
@@ -30,6 +30,9 @@
if not os.getenv("SPHINX_NO_DESCRIPTIONS"):
extensions.append("godot_descriptions")

if not os.getenv("SPHINX_NO_QUESTIONS_ANSWERS"):
extensions.append("godot_questions_answers")

templates_path = ["_templates"]

# You can specify multiple suffix as a list of string: ['.rst', '.md']
2 changes: 2 additions & 0 deletions tutorials/animation/2d_skeletons.rst
Original file line number Diff line number Diff line change
@@ -238,3 +238,5 @@ painting! Go to the *Bones* section again to assign them to the right bones.
Once you are all set, you will get much better results:

.. image:: img/skel2d25.gif

.. questions-answers:: 2d skeleton
2 changes: 2 additions & 0 deletions tutorials/animation/animation_track_types.rst
Original file line number Diff line number Diff line change
@@ -116,3 +116,5 @@ a key and have it set to `[STOP]` in the inspector.
scene, you need to enable "Editable Children" in the scene tree to
access its animation player. Also, an animation player cannot
reference itself.

.. questions-answers:: animation track
2 changes: 2 additions & 0 deletions tutorials/animation/animation_tree.rst
Original file line number Diff line number Diff line change
@@ -261,3 +261,5 @@ Once retrieved, it can be used by calling one of the many functions it offers:
.. code-tab:: csharp

stateMachine.Travel("SomeState")

.. questions-answers:: animationtree
6 changes: 4 additions & 2 deletions tutorials/animation/cutout_animation.rst
Original file line number Diff line number Diff line change
@@ -236,14 +236,14 @@ position of hands, feet and other extremities of rigs like the one we've made.
Imagine you want to pose a character's foot in a specific position on the ground.
Without IK chains, each motion of the foot would require rotating and positioning
several other bones (the shin and the thigh at least). This would be quite
complex and lead to imprecise results. IK allows us to move the foot directly
complex and lead to imprecise results. IK allows us to move the foot directly
while the shin and thigh self-adjust.

.. note::

**IK chains in Godot currently work in the editor only**, not
at runtime. They are intended to ease the process of setting keyframes, and are
not currently useful for techniques like procedural animation.
not currently useful for techniques like procedural animation.

To create an IK chain, select a chain of bones from endpoint to
the base for the chain. For example, to create an IK chain for the right
@@ -374,3 +374,5 @@ Skeletal deform can be used to augment a cutout rig, allowing single pieces to
deform organically (e.g. antennae that wobble as an insect character walks).

This process is described in a :ref:`separate tutorial <doc_2d_skeletons>`.

.. questions-answers:: animation cutout
2 changes: 2 additions & 0 deletions tutorials/animation/introduction.rst
Original file line number Diff line number Diff line change
@@ -310,3 +310,5 @@ You usually tweak your animations this way, when the movement doesn't

.. |Play from beginning| image:: img/animation_play_from_beginning.png
.. |Add Animation| image:: img/animation_add.png

.. questions-answers:: animation
2 changes: 2 additions & 0 deletions tutorials/audio/audio_buses.rst
Original file line number Diff line number Diff line change
@@ -293,3 +293,5 @@ Default bus layout
The default bus layout is automatically saved to the
``res://default_bus_layout.tres`` file. Custom bus arrangements can be saved
and loaded from disk.

.. questions-answers:: audio
4 changes: 3 additions & 1 deletion tutorials/audio/audio_streams.rst
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ your use case best:
at relatively low bitrates.

Keep in mind that while WAV files may contain looping information in their metadata,
Ogg Vorbis files do not. If looping an Ogg Vorbis file is desired,
Ogg Vorbis files do not. If looping an Ogg Vorbis file is desired,
it must be set up using the import options:

.. image:: img/audio_stream_import.png
@@ -113,3 +113,5 @@ Enable it by setting it depending on how objects will be moved:
use **Idle** for objects moved using ``_process``, or **Physics**
for objects moved using ``_physics_process``. The tracking will
happen automatically.

.. questions-answers:: audio
2 changes: 2 additions & 0 deletions tutorials/audio/recording_with_microphone.rst
Original file line number Diff line number Diff line change
@@ -97,3 +97,5 @@ To playback the recording, you assign the recording as the stream of the

To save the recording, you call ``save_to_wav()`` with the path to a file.
In this demo, the path is defined by the user via a ``LineEdit`` input box.

.. questions-answers:: audio record
2 changes: 2 additions & 0 deletions tutorials/audio/sync_with_audio.rst
Original file line number Diff line number Diff line change
@@ -100,3 +100,5 @@ Here is the same code as before using this approach:
# Compensate for output latency.
time -= AudioServer.get_output_latency()
print("Time is: ", time)

.. questions-answers:: audio
2 changes: 2 additions & 0 deletions tutorials/editor/command_line_tutorial.rst
Original file line number Diff line number Diff line change
@@ -348,3 +348,5 @@ always have the shebang run Godot straight from where it is located as follows:
::

#!/usr/bin/godot -s

.. questions-answers:: command-line
2 changes: 2 additions & 0 deletions tutorials/editor/external_editor.rst
Original file line number Diff line number Diff line change
@@ -62,3 +62,5 @@ We have official plugins for the following code editors:

- `Visual Studio Code <https://github.com/godotengine/godot-vscode-plugin>`_
- `Emacs <https://github.com/godotengine/emacs-gdscript-mode>`_

.. questions-answers:: external-editor
2 changes: 2 additions & 0 deletions tutorials/export/exporting_for_android.rst
Original file line number Diff line number Diff line change
@@ -139,3 +139,5 @@ and ARMv8 is usually sufficient to cover most devices in use today.
You can optimize the size further by compiling an Android export template with
only the features you need. See :ref:`doc_optimizing_for_size` for more
information.

.. questions-answers:: export android
2 changes: 2 additions & 0 deletions tutorials/export/exporting_for_dedicated_servers.rst
Original file line number Diff line number Diff line change
@@ -123,3 +123,5 @@ If you have experience with containers, you could also look into wrapping your
dedicated server in a `Docker <https://www.docker.com/>`__ container. This way,
it can be used more easily in an automatic scaling setup (which is outside the
scope of this tutorial).

.. questions-answers:: export server
2 changes: 2 additions & 0 deletions tutorials/export/exporting_for_ios.rst
Original file line number Diff line number Diff line change
@@ -98,3 +98,5 @@ Services for iOS

Special iOS services can be used in Godot. Check out the
:ref:`doc_services_for_ios` page.

.. questions-answers:: export ios
2 changes: 2 additions & 0 deletions tutorials/export/exporting_for_pc.rst
Original file line number Diff line number Diff line change
@@ -17,3 +17,5 @@ does not contain the editor and debugger.

If you export for Windows with embedded PCK files, you will not be able to
sign the program, it will break.

.. questions-answers:: export desktop
2 changes: 2 additions & 0 deletions tutorials/export/exporting_for_uwp.rst
Original file line number Diff line number Diff line change
@@ -94,3 +94,5 @@ It's also possible to install by using the ``Add-AppxPackage`` PowerShell cmdlet
.. note:: If you want to update your already installed app, you must
update the version number on the new package or first uninstall
the previous package.

.. questions-answers:: export uwp
2 changes: 2 additions & 0 deletions tutorials/export/exporting_for_web.rst
Original file line number Diff line number Diff line change
@@ -244,3 +244,5 @@ defaulting to ``false`` to prevent polluting the global namespace::
# execute in global execution context,
# thus adding a new JavaScript global variable `SomeGlobal`
JavaScript.eval("var SomeGlobal = {};", true)

.. questions-answers:: export html5
2 changes: 2 additions & 0 deletions tutorials/export/exporting_pcks.rst
Original file line number Diff line number Diff line change
@@ -136,3 +136,5 @@ is. The most important thing is to identify how one plans to distribute future
content for their game and develop a workflow that is customized for that
purpose. Godot should make that process smooth regardless of which route a
developer pursues.

.. questions-answers:: export pck
2 changes: 2 additions & 0 deletions tutorials/export/exporting_projects.rst
Original file line number Diff line number Diff line change
@@ -176,3 +176,5 @@ depending on your needs.
- Compressed format. Smaller file size, but slower to read/write.
- Readable and writable using tools normally present on the user's operating system.
This can be useful to make modding easier (see also :ref:`doc_exporting_pcks`).

.. questions-answers:: export
2 changes: 2 additions & 0 deletions tutorials/export/feature_tags.rst
Original file line number Diff line number Diff line change
@@ -124,3 +124,5 @@ Customizing the build

Feature tags can be used to customize a build process too, by writing a custom **ExportPlugin**.
They are also used to specify which shared library is loaded and exported in **GDNative**.

.. questions-answers:: feature-tags
2 changes: 2 additions & 0 deletions tutorials/export/one-click_deploy.rst
Original file line number Diff line number Diff line change
@@ -29,3 +29,5 @@ Steps for one-click deploy
.. image:: img/oneclick.png

Click once... and deploy!

.. questions-answers:: one-click-deploy
2 changes: 2 additions & 0 deletions tutorials/i18n/internationalizing_games.rst
Original file line number Diff line number Diff line change
@@ -121,3 +121,5 @@ For instance, for Spanish, this would be ``application/name_es``:

If you are unsure about the language code to use, refer to the
:ref:`list of locale codes <doc_locales>`.

.. questions-answers:: localization
2 changes: 2 additions & 0 deletions tutorials/i18n/localization_using_gettext.rst
Original file line number Diff line number Diff line change
@@ -177,3 +177,5 @@ the command below:
If there are syntax errors or warnings, they will be displayed in the console.
Otherwise, ``msgfmt`` won't output anything.

.. questions-answers:: localization
2 changes: 2 additions & 0 deletions tutorials/physics/collision_shapes_2d.rst
Original file line number Diff line number Diff line change
@@ -130,3 +130,5 @@ If you run into performance issues, you may have to make tradeoffs in terms of
accuracy. Most games out there don't have a 100% accurate collision. They find
creative ways to hide it or otherwise make it unnoticeable during normal
gameplay.

.. questions-answers:: 2d physics collision
2 changes: 2 additions & 0 deletions tutorials/physics/collision_shapes_3d.rst
Original file line number Diff line number Diff line change
@@ -143,3 +143,5 @@ If you run into performance issues, you may have to make tradeoffs in terms of
accuracy. Most games out there don't have a 100% accurate collision. They find
creative ways to hide it or otherwise make it unnoticeable during normal
gameplay.

.. questions-answers:: 3d physics collision
2 changes: 2 additions & 0 deletions tutorials/physics/kinematic_character_2d.rst
Original file line number Diff line number Diff line change
@@ -254,3 +254,5 @@ And give it a try.
This is a good starting point for a platformer. A more complete demo can be found in the demo zip distributed with the
engine, or in the
https://github.com/godotengine/godot-demo-projects/tree/master/2d/kinematic_character.

.. questions-answers:: physics kinematic character
2 changes: 2 additions & 0 deletions tutorials/physics/physics_introduction.rst
Original file line number Diff line number Diff line change
@@ -493,3 +493,5 @@ the ground (including slopes) and jump when standing on the ground:

See :ref:`doc_kinematic_character_2d` for more details on using ``move_and_slide()``,
including a demo project with detailed code.

.. questions-answers:: physics
2 changes: 2 additions & 0 deletions tutorials/physics/ragdoll_system.rst
Original file line number Diff line number Diff line change
@@ -84,3 +84,5 @@ Make sure to set up your collision layers and masks properly so the ``KinematicB
.. image:: img/ragdoll_layer.png

For more information, read :ref:`doc_physics_introduction_collision_layers_and_masks`.

.. questions-answers:: physics ragdoll
2 changes: 2 additions & 0 deletions tutorials/physics/ray-casting.rst
Original file line number Diff line number Diff line change
@@ -270,3 +270,5 @@ To obtain it using a camera, the following code can be used:

Remember that during ``_input()``, the space may be locked, so in practice
this query should be run in ``_physics_process()``.

.. questions-answers:: physics raycast
2 changes: 2 additions & 0 deletions tutorials/physics/rigid_body.rst
Original file line number Diff line number Diff line change
@@ -69,3 +69,5 @@ Here is a custom ``look_at()`` method that will work reliably with rigid bodies:
This method uses the rigid body's ``set_angular_velocity()`` method to rotate the body. It first calculates the difference between the current and desired angle and then adds the velocity needed to rotate by that amount in one frame's time.

.. note:: This script will not work with rigid bodies in *character mode* because then, the body's rotation is locked. In that case, you would have to rotate the attached mesh node instead using the standard Spatial methods.

.. questions-answers:: physics rigidbody
2 changes: 2 additions & 0 deletions tutorials/physics/soft_body.rst
Original file line number Diff line number Diff line change
@@ -65,3 +65,5 @@ Play the scene and the cloak should simulate correctly.
.. image:: img/softbody_cloak_finish.png

This covers the basic settings of softbody, experiment with the parameters to achieve the effect you are aiming for when making your game.

.. questions-answers:: physics softbody
2 changes: 2 additions & 0 deletions tutorials/physics/using_area_2d.rst
Original file line number Diff line number Diff line change
@@ -138,3 +138,5 @@ override.

You can download this project here:
:download:`using_area_2d.zip <files/using_area_2d.zip>`

.. questions-answers:: physics area
4 changes: 3 additions & 1 deletion tutorials/physics/using_kinematic_body_2d.rst
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ and ``get_slide_collision()``:
var collision = get_slide_collision(i)
print("I collided with ", collision.collider.name)

.. note:: `get_slide_count()` only counts times the body has collided and changed direction.
.. note:: `get_slide_count()` only counts times the body has collided and changed direction.

See :ref:`KinematicCollision2D <class_KinematicCollision2D>` for details on what
collision data is returned.
@@ -571,3 +571,5 @@ vector. You can control the maximum angle by setting ``floor_max_angle``.

This angle also allows you to implement other features like wall jumps using
``is_on_wall()``, for example.

.. questions-answers:: physics kinematicbody
2 changes: 2 additions & 0 deletions tutorials/rendering/multiple_resolutions.rst
Original file line number Diff line number Diff line change
@@ -305,3 +305,5 @@ better in many cases.
See the
`3D viewport scaling demo <https://github.com/godotengine/godot-demo-projects/tree/master/viewport/3d_scaling>`__
for examples.

.. questions-answers:: resolution scaling
2 changes: 2 additions & 0 deletions tutorials/rendering/viewports.rst
Original file line number Diff line number Diff line change
@@ -252,3 +252,5 @@ incurring the cost of rendering every frame.
Make sure to check the Viewport demos! Viewport folder in the demos
archive available to download, or
https://github.com/godotengine/godot-demo-projects/tree/master/viewport

.. questions-answers:: viewport
2 changes: 2 additions & 0 deletions tutorials/scripting/cross_language_scripting.rst
Original file line number Diff line number Diff line change
@@ -208,3 +208,5 @@ inherit from a GDScript file. Due to how complex this would be to implement,
this limitation is unlikely to be lifted in the future. See
`this GitHub issue <https://github.com/godotengine/godot/issues/38352>`__
for more information.

.. questions-answers:: cross language scripting
2 changes: 2 additions & 0 deletions tutorials/scripting/groups.rst
Original file line number Diff line number Diff line change
@@ -122,3 +122,5 @@ The :ref:`SceneTree <class_SceneTree>` class provides many more useful methods
to interact with scenes, their node hierarchy, and groups. It allows you to
switch scenes easily or reload them, quit the game or pause and unpause it. It
also provides useful signals.

.. questions-answers:: groups
2 changes: 2 additions & 0 deletions tutorials/scripting/instancing_with_signals.rst
Original file line number Diff line number Diff line change
@@ -156,3 +156,5 @@ Now the bullets will maintain their own movement independent of the player's
rotation:

.. image:: img/signals_shoot2.gif

.. questions-answers:: instancing signals
2 changes: 2 additions & 0 deletions tutorials/scripting/pausing_games.rst
Original file line number Diff line number Diff line change
@@ -125,3 +125,5 @@ closed:
}

And that should be all!

.. questions-answers:: pause

0 comments on commit 84f8a24

Please sign in to comment.