doc: Document the default namespaces.

Right now, this is mostly hidden, intended to supply information
to vscode completion.
This commit is contained in:
Tom Rothamel
2024-07-09 23:16:00 -04:00
parent 0db128da75
commit e6d8522b96
4 changed files with 149 additions and 3 deletions
+25
View File
@@ -116,6 +116,8 @@ class Documentation:
li = LineIterator(i)
self.parse_file(basename, li)
self.output("renpy", "image", "black", " = Solid(\"#000\")", "A solid black color.")
def parse_file(self, basename, li):
"""
Parses a file and updates the documentation with the contents.
@@ -255,6 +257,28 @@ class Documentation:
else:
self.renpy[name] = entry
def check_namespaces(self):
"""
Checks that all namespaces have at least some documentation.
"""
namespaces = set()
for name in list(self.renpy.keys()) + list(self.config.keys()):
if not "." in name:
continue
namespace = name.rpartition(".")[0]
namespaces.add(namespace)
for i in sorted(namespaces):
if i in { "_preferences", "emscripten", "renpy.audio" }:
continue
if i not in self.renpy and i not in self.config:
print("Namespace", i, "is not documented.")
def main():
d = Documentation()
@@ -271,6 +295,7 @@ def main():
with open(SPHINX + "/renpy.json", "w") as f:
json.dump(renpy_json, f, indent=2)
d.check_namespaces()
if __name__ == '__main__':
main()
+6 -2
View File
@@ -54,8 +54,12 @@ steamapi module, as found `here <https://github.com/renpy/renpy-build/blob/maste
and represents a machine translation of the C++ Steamworks API to Python.
In addition, a large number of functions are available in the achievement.steam object, if and only
if the Steamworks API is available. The ``achievement.steam`` object will be None if Steam is not
present or initialized. Check the value of ``achievement.steam`` before using it.
if the Steamworks API is available.
.. var:: achievement.steam
If Steam initialized successfully, this is a namespace with high-level Steam methods. If Steam did not
initialize, this is None. Always check that this is not None before calling a method.
Steam Apps
^^^^^^^^^^
+117
View File
@@ -0,0 +1,117 @@
:orphan:
Namespaces
==========
Ren'Py uses namespaces to organize variables and methods. This file contains descriptions of some of the
namespaces Ren'Py uses, primarily to help editors provide autocompletion and documentation.
.. var:: achievement
A namespace that contains functions that grant and manage :doc:`achievements <achievement>`. This also contains much of
the Steamworks integration.
.. var:: bubble:
A namespace that contains variables that control the display of :doc:`dialogue bubbles <bubble>`.
.. var:: build:
A namespace that contains variables that control the :doc:`build process <build>`.
.. var:: config:
A namespace that contains variables that control the :doc:`configuration <config>` of Ren'Py. These variables should
be set at init time (in ``init python`` blocks or with the ``define``) and should not be changed once the game
has started.
.. var:: define:
The define namespace contains functions that define new variables, such as families of transitions.
.. var:: director:
The director namespace contains functions that control the :doc:`interactive director <director>`, which
lets you insert images and music into the game interactively.
.. var:: gui
The gui namespace contains functions that control the :doc:`default GUI system <gui>`. These variables only matter
if you are using the default GUI system, and may not be used if you've replaced it. Define statements that
affect the gui namespace are re-run when the translaton changes.
.. var:: iap
The iap namespace contains functions that control the :doc:`in-app purchase system <iap>`.
.. var:: im
**Note: Most functions in the im namespace are deprecated.**
The im namespace contains image manipulators, which load or manipulate images on the CPU. Most functions here
can be accomplished on the GPU using :class:`Transform`.
.. var:: layeredimage
:doc:`Layered images <layeredimage>` are a way to combine multiple images into a single image, using attributes
and conditions to control which images are shown. The layeredimage namespace contains classes that allow you
to create and manipulate layered images from Python, the equivalent of the ``layeredimage`` statement.
.. var:: persistent
The persistent namespace contains :doc:`persistent` data. Fields on this object start as None, and retain
their values between runs of the game, even when not loading a save slot.
The values of fields on the persistent object should be of Python-supplied types, like booleans, numbers,
strings, lists, tuples, dicts, and sets. Classes you define should not be assigned to the persistent object.
.. var:: preferences
The :doc:`preferences` namespace contains variables that contain preferences. While these can be read and set,
the most common use is with the ``default`` statement, using syntax like::
default preferences.fullscreen = True
.. var:: preferences.volume
The :doc:`preferences` namespace contains variables that set the default volumes for each mixer. These should
be set using the ``default`` statement, like::
default preferences.volume.music = 0.5
.. var:: renpy
The renpy namespace contains function and classes that are part of the Ren'Py engine itself. These can be the
equivalent of Ren'Py language statements, or can introduce functionality that does not merit a dedicated statement.
.. var:: renpy.audio.filter
The renpy.audio.filter namespace contains classes and functions that create :doc:`audio filters <audio_filters>`.
.. var:: renpy.music
The renpy.audio.music namespace contains functions that control the :doc:`audio system <audio>`. These functions
work with the music channel by default.
.. var:: renpy.sound
The renpy.audio.sound namespace contains functions that control the :doc:`audio system <audio>`. These functions
work with the sound channel by default. Most functions are documented under their renpy.music equivalents.
.. var:: style
The style namespace contains styles and functions that manipulate styles. Styles are used to control the appearance
of text, images, and other elements in Ren'Py. Using the ``style`` statement is preferred to using the style
namespace directly.
.. var:: ui
**Note: Most functions in the ui namespace are deprecated.**
The ui namespace contains older functions and classes used to display user interface elements. With the the exception
of ui.adjustment, ui.interact, ui.callsinnewcontext, and ui.invokesinnewcontext, these functions are
obsolete.
.. var:: updater
The updater namespace contains functions, classes, and variables that control the :doc:`HTTP/HTTPS <updater>`.
+1 -1
View File
@@ -118,7 +118,7 @@ The updater screen is supplied a single parameter, an Updater object, which
must be named `u`. The Updater object has the following fields on it, which
can be used to customize the screen:
.. class:: update.Updater
.. class:: updater.Updater
.. attribute:: state