Skip to content

Commit 5593f2e

Browse files
add docstrings for structs and enums, fixes issue #159
1 parent 002e4ca commit 5593f2e

21 files changed

+745
-1174
lines changed

create_enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def process(filename):
2424
for e in js['enums']:
2525
if e['name'] and e['values']:
2626
print ("class "+e['name']+"("+"IntEnum):")
27+
print(f' """{e['description']}."""')
2728
for value in e['values']:
2829
print(" "+value['name']+" = "+str(value['value']))
2930
print("")

create_stub_pyray.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
known_structs[st["name"]] = st
3333
for e in js['enums']:
3434
if e['name'] and e['values']:
35-
print ("class "+e['name']+"(int):")
35+
print("class "+e['name']+"(int):")
36+
print(f' """{e['description']}."""')
3637
for value in e['values']:
3738
print(" "+value['name']+" = "+str(value['value']))
3839
print("")
@@ -144,7 +145,7 @@ def ctype_to_python_type(t):
144145
print("weird empty struct, skipping " + struct, file=sys.stderr)
145146
continue
146147
print(f"class {struct}:")
147-
print(f' """ struct """')
148+
print(f' """{known_structs[struct]['description']}."""')
148149
sig = ""
149150
for arg in ffi.typeof(struct).fields:
150151
ptype = ctype_to_python_type(arg[1].type.cname)

docs/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 6b88b88b20947586d6498748ffd23a92
3+
config: f2032a6434b52f7c68551d0ad70d555b
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/BUILDING.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
99
<title>Building from source &mdash; Raylib Python documentation</title>
10-
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
10+
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
1313

docs/README.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
99
<title>Python Bindings for Raylib 5.5 &mdash; Raylib Python documentation</title>
10-
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
10+
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
1313

@@ -142,7 +142,7 @@ <h2>Platforms: Windows, Mac, Linux, Raspberry Pi, Web<a class="headerlink" href=
142142
<section id="quickstart">
143143
<h1>Quickstart<a class="headerlink" href="#quickstart" title="Link to this heading"></a></h1>
144144
<p><code class="docutils literal notranslate"><span class="pre">pip3</span> <span class="pre">install</span> <span class="pre">raylib==5.5.0.2</span> <span class="pre">--break-system-packages</span></code></p>
145-
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pyray</span> <span class="kn">import</span> <span class="o">*</span>
145+
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">pyray</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
146146
<span class="n">init_window</span><span class="p">(</span><span class="mi">800</span><span class="p">,</span> <span class="mi">450</span><span class="p">,</span> <span class="s2">&quot;Hello&quot;</span><span class="p">)</span>
147147
<span class="k">while</span> <span class="ow">not</span> <span class="n">window_should_close</span><span class="p">():</span>
148148
<span class="n">begin_drawing</span><span class="p">()</span>
@@ -202,7 +202,7 @@ <h2>Linux<a class="headerlink" href="#linux" title="Link to this heading"></a
202202
</section>
203203
<section id="raspberry-pi">
204204
<h2>Raspberry Pi<a class="headerlink" href="#raspberry-pi" title="Link to this heading"></a></h2>
205-
<p><a class="reference internal" href="RPI.html"><span class="std std-doc">Using on Rasperry Pi</span></a></p>
205+
<p><span class="xref myst">Using on Rasperry Pi</span></p>
206206
</section>
207207
</section>
208208
<section id="backends">
@@ -237,7 +237,7 @@ <h2>DRM backend<a class="headerlink" href="#drm-backend" title="Link to this hea
237237
</section>
238238
<section id="problems">
239239
<h2>Problems?<a class="headerlink" href="#problems" title="Link to this heading"></a></h2>
240-
<p>If it doesn’t work, <a class="reference internal" href="BUILDING.html"><span class="std std-doc">try to build manually.</span></a>. If that works then <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/issues">submit an issue</a>
240+
<p>If it doesn’t work, <span class="xref myst">try to build manually.</span>. If that works then <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/issues">submit an issue</a>
241241
to let us know what you did.</p>
242242
<p>If you need help you can try asking on <a class="reference external" href="https://discord.gg/fKDwt85aX6">our discord</a>. There is also a large <a class="reference external" href="https://discord.gg/raylib">Raylib discord</a>
243243
for issues that are not Python-specific.</p>
@@ -268,11 +268,11 @@ <h1>Running in a web browser<a class="headerlink" href="#running-in-a-web-browse
268268
<span class="c1"># &quot;raylib&quot;</span>
269269
<span class="c1"># ]</span>
270270
<span class="c1"># ///</span>
271-
<span class="kn">import</span> <span class="nn">asyncio</span>
272-
<span class="kn">import</span> <span class="nn">platform</span>
273-
<span class="kn">from</span> <span class="nn">pyray</span> <span class="kn">import</span> <span class="o">*</span>
271+
<span class="kn">import</span><span class="w"> </span><span class="nn">asyncio</span>
272+
<span class="kn">import</span><span class="w"> </span><span class="nn">platform</span>
273+
<span class="kn">from</span><span class="w"> </span><span class="nn">pyray</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
274274

275-
<span class="k">async</span> <span class="k">def</span> <span class="nf">main</span><span class="p">():</span> <span class="c1"># You MUST have an async main function</span>
275+
<span class="k">async</span> <span class="k">def</span><span class="w"> </span><span class="nf">main</span><span class="p">():</span> <span class="c1"># You MUST have an async main function</span>
276276
<span class="n">init_window</span><span class="p">(</span><span class="mi">500</span><span class="p">,</span> <span class="mi">500</span><span class="p">,</span> <span class="s2">&quot;Hello&quot;</span><span class="p">)</span>
277277
<span class="n">platform</span><span class="o">.</span><span class="n">window</span><span class="o">.</span><span class="n">window_resize</span><span class="p">()</span> <span class="c1"># You MAY want to add this line</span>
278278
<span class="k">while</span> <span class="ow">not</span> <span class="n">window_should_close</span><span class="p">():</span>

docs/RPI.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
99
<title>Raspberry Pi &mdash; Raylib Python documentation</title>
10-
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
10+
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
1313

docs/_static/basic.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -741,14 +741,6 @@ abbr, acronym {
741741
cursor: help;
742742
}
743743

744-
.translated {
745-
background-color: rgba(207, 255, 207, 0.2)
746-
}
747-
748-
.untranslated {
749-
background-color: rgba(255, 207, 207, 0.2)
750-
}
751-
752744
/* -- code displays --------------------------------------------------------- */
753745

754746
pre {

docs/_static/js/versions.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
const themeFlyoutDisplay = "hidden";
2-
const themeVersionSelector = "True";
3-
const themeLanguageSelector = "True";
2+
const themeVersionSelector = true;
3+
const themeLanguageSelector = true;
44

55
if (themeFlyoutDisplay === "attached") {
66
function renderLanguages(config) {
77
if (!config.projects.translations.length) {
88
return "";
99
}
1010

11+
// Insert the current language to the options on the selector
12+
let languages = config.projects.translations.concat(config.projects.current);
13+
languages = languages.sort((a, b) => a.language.name.localeCompare(b.language.name));
14+
1115
const languagesHTML = `
1216
<dl>
1317
<dt>Languages</dt>
14-
${config.projects.translations
18+
${languages
1519
.map(
1620
(translation) => `
1721
<dd ${translation.slug == config.projects.current.slug ? 'class="rtd-current-item"' : ""}>

docs/_static/pygments.css

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,70 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
66
.highlight .hll { background-color: #ffffcc }
77
.highlight { background: #eeffcc; }
88
.highlight .c { color: #408090; font-style: italic } /* Comment */
9-
.highlight .err { border: 1px solid #FF0000 } /* Error */
9+
.highlight .err { border: 1px solid #F00 } /* Error */
1010
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
11-
.highlight .o { color: #666666 } /* Operator */
11+
.highlight .o { color: #666 } /* Operator */
1212
.highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
1313
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
1414
.highlight .cp { color: #007020 } /* Comment.Preproc */
1515
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
1616
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
17-
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
17+
.highlight .cs { color: #408090; background-color: #FFF0F0 } /* Comment.Special */
1818
.highlight .gd { color: #A00000 } /* Generic.Deleted */
1919
.highlight .ge { font-style: italic } /* Generic.Emph */
2020
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
21-
.highlight .gr { color: #FF0000 } /* Generic.Error */
21+
.highlight .gr { color: #F00 } /* Generic.Error */
2222
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
2323
.highlight .gi { color: #00A000 } /* Generic.Inserted */
24-
.highlight .go { color: #333333 } /* Generic.Output */
25-
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
24+
.highlight .go { color: #333 } /* Generic.Output */
25+
.highlight .gp { color: #C65D09; font-weight: bold } /* Generic.Prompt */
2626
.highlight .gs { font-weight: bold } /* Generic.Strong */
2727
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
28-
.highlight .gt { color: #0044DD } /* Generic.Traceback */
28+
.highlight .gt { color: #04D } /* Generic.Traceback */
2929
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
3030
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
3131
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
3232
.highlight .kp { color: #007020 } /* Keyword.Pseudo */
3333
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
3434
.highlight .kt { color: #902000 } /* Keyword.Type */
3535
.highlight .m { color: #208050 } /* Literal.Number */
36-
.highlight .s { color: #4070a0 } /* Literal.String */
37-
.highlight .na { color: #4070a0 } /* Name.Attribute */
36+
.highlight .s { color: #4070A0 } /* Literal.String */
37+
.highlight .na { color: #4070A0 } /* Name.Attribute */
3838
.highlight .nb { color: #007020 } /* Name.Builtin */
39-
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
40-
.highlight .no { color: #60add5 } /* Name.Constant */
41-
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
42-
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
39+
.highlight .nc { color: #0E84B5; font-weight: bold } /* Name.Class */
40+
.highlight .no { color: #60ADD5 } /* Name.Constant */
41+
.highlight .nd { color: #555; font-weight: bold } /* Name.Decorator */
42+
.highlight .ni { color: #D55537; font-weight: bold } /* Name.Entity */
4343
.highlight .ne { color: #007020 } /* Name.Exception */
44-
.highlight .nf { color: #06287e } /* Name.Function */
44+
.highlight .nf { color: #06287E } /* Name.Function */
4545
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
46-
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
46+
.highlight .nn { color: #0E84B5; font-weight: bold } /* Name.Namespace */
4747
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
48-
.highlight .nv { color: #bb60d5 } /* Name.Variable */
48+
.highlight .nv { color: #BB60D5 } /* Name.Variable */
4949
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
50-
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
50+
.highlight .w { color: #BBB } /* Text.Whitespace */
5151
.highlight .mb { color: #208050 } /* Literal.Number.Bin */
5252
.highlight .mf { color: #208050 } /* Literal.Number.Float */
5353
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
5454
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
5555
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
56-
.highlight .sa { color: #4070a0 } /* Literal.String.Affix */
57-
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
58-
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
59-
.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
60-
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
61-
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
62-
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
63-
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
64-
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
65-
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
56+
.highlight .sa { color: #4070A0 } /* Literal.String.Affix */
57+
.highlight .sb { color: #4070A0 } /* Literal.String.Backtick */
58+
.highlight .sc { color: #4070A0 } /* Literal.String.Char */
59+
.highlight .dl { color: #4070A0 } /* Literal.String.Delimiter */
60+
.highlight .sd { color: #4070A0; font-style: italic } /* Literal.String.Doc */
61+
.highlight .s2 { color: #4070A0 } /* Literal.String.Double */
62+
.highlight .se { color: #4070A0; font-weight: bold } /* Literal.String.Escape */
63+
.highlight .sh { color: #4070A0 } /* Literal.String.Heredoc */
64+
.highlight .si { color: #70A0D0; font-style: italic } /* Literal.String.Interpol */
65+
.highlight .sx { color: #C65D09 } /* Literal.String.Other */
6666
.highlight .sr { color: #235388 } /* Literal.String.Regex */
67-
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
67+
.highlight .s1 { color: #4070A0 } /* Literal.String.Single */
6868
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
6969
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
70-
.highlight .fm { color: #06287e } /* Name.Function.Magic */
71-
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
72-
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
73-
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
74-
.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
70+
.highlight .fm { color: #06287E } /* Name.Function.Magic */
71+
.highlight .vc { color: #BB60D5 } /* Name.Variable.Class */
72+
.highlight .vg { color: #BB60D5 } /* Name.Variable.Global */
73+
.highlight .vi { color: #BB60D5 } /* Name.Variable.Instance */
74+
.highlight .vm { color: #BB60D5 } /* Name.Variable.Magic */
7575
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */

docs/_static/searchtools.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,11 @@ const Search = {
513513
// perform the search on the required terms
514514
searchTerms.forEach((word) => {
515515
const files = [];
516+
// find documents, if any, containing the query word in their text/title term indices
517+
// use Object.hasOwnProperty to avoid mismatching against prototype properties
516518
const arr = [
517-
{ files: terms[word], score: Scorer.term },
518-
{ files: titleTerms[word], score: Scorer.title },
519+
{ files: terms.hasOwnProperty(word) ? terms[word] : undefined, score: Scorer.term },
520+
{ files: titleTerms.hasOwnProperty(word) ? titleTerms[word] : undefined, score: Scorer.title },
519521
];
520522
// add support for partial matches
521523
if (word.length > 2) {
@@ -547,8 +549,9 @@ const Search = {
547549

548550
// set score for the word in each file
549551
recordFiles.forEach((file) => {
550-
if (!scoreMap.has(file)) scoreMap.set(file, {});
551-
scoreMap.get(file)[word] = record.score;
552+
if (!scoreMap.has(file)) scoreMap.set(file, new Map());
553+
const fileScores = scoreMap.get(file);
554+
fileScores.set(word, record.score);
552555
});
553556
});
554557

@@ -587,7 +590,7 @@ const Search = {
587590
break;
588591

589592
// select one (max) score for the file.
590-
const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w]));
593+
const score = Math.max(...wordList.map((w) => scoreMap.get(file).get(w)));
591594
// add result to the result list
592595
results.push([
593596
docNames[file],

0 commit comments

Comments
 (0)