Skip to content

Commit 8f61771

Browse files
committed
Structure the 'Areas and teams' page with tables, derived from the website "Teams" page tables.
1 parent e81b33c commit 8f61771

File tree

4 files changed

+251
-141
lines changed

4 files changed

+251
-141
lines changed

_extensions/area_table.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
"""
2+
A directive for organization/areas.rst to render the area tables.
3+
"""
4+
5+
from docutils import nodes
6+
from docutils.parsers.rst import Directive
7+
import re
8+
9+
area_table_rows = ["Communication", "GitHub reviews", "GitHub labels", "Triage project"]
10+
11+
channel_re = re.compile(r'#([\w-]+)')
12+
godot_team_re = re.compile(r'@godotengine/([\w-]+)')
13+
labels_re = re.compile(r'<gh-label>(.+?)</gh-label>')
14+
triage_re = re.compile(r'<gh-triage project=(\d+)>(.*?)</gh-triage>')
15+
16+
17+
def transform_channels(match: re.Match):
18+
old_value = match.group(1)
19+
transformed = f'<a href="https://chat.godotengine.org/channel/{old_value}">#{old_value}</a>'
20+
return transformed
21+
22+
23+
def transform_github_teams(match: re.Match):
24+
old_value = match.group(1)
25+
transformed = f'<a href="https://github.com/godotengine/godot/pulls?q=is%3Apr+is%3Aopen+team-review-requested%3Agodotengine%2F{old_value}">@godotengine/{old_value}</a>'
26+
return transformed
27+
28+
29+
def transform_github_labels(match: re.Match):
30+
old_value = match.group(1)
31+
transformed = f'<code class="docutils literal notranslate"><span class="pre">{old_value}</span></code> (<a href="https://github.com/godotengine/godot/issues?q=is%3Aissue%20state%3Aopen%20label%3A{old_value}">issues</a>, <a href="https://github.com/godotengine/godot/pulls?q=is%3Apr+is%3Aopen+label%3A{old_value}">PRs</a>)'
32+
return transformed
33+
34+
35+
def transform_github_triage(match: re.Match):
36+
number = match.group(1)
37+
name = match.group(2)
38+
transformed = f'<a href="https://github.com/orgs/godotengine/projects/{number}">{name}</a>'
39+
return transformed
40+
41+
42+
class TableDirective(Directive):
43+
has_content = False
44+
required_arguments = 0
45+
optional_arguments = 0
46+
final_argument_whitespace = False
47+
option_spec = {column.lower().replace(" ", "_"): str for column in area_table_rows}
48+
49+
def run(self):
50+
# Create a table node with the parsed header and data
51+
table = nodes.table()
52+
table.setdefault('classes', []).append("gdarea-table")
53+
tgroup = nodes.tgroup(cols=2)
54+
table += tgroup
55+
56+
# Set column specifications
57+
tgroup += nodes.colspec(colwidth=2)
58+
tgroup += nodes.colspec(colwidth=5)
59+
60+
# Create and add the table body
61+
tbody = nodes.tbody()
62+
tgroup += tbody
63+
for column_title in area_table_rows:
64+
row_text = self.options.get(column_title.lower().replace(" ", "_"), '')
65+
if not row_text:
66+
continue
67+
68+
body_row = nodes.row()
69+
70+
entry = nodes.entry()
71+
entry.setdefault('classes', []).append("gdarea-table-header")
72+
entry += nodes.paragraph(text=column_title)
73+
body_row += entry
74+
75+
row_text = channel_re.sub(transform_channels, row_text)
76+
row_text = godot_team_re.sub(transform_github_teams, row_text)
77+
row_text = labels_re.sub(transform_github_labels, row_text)
78+
row_text = triage_re.sub(transform_github_triage, row_text)
79+
80+
entry = nodes.entry()
81+
paragraph = nodes.paragraph()
82+
paragraph += nodes.raw('', row_text, format='html')
83+
entry += paragraph
84+
body_row += entry
85+
86+
tbody += body_row
87+
88+
return [table]
89+
90+
91+
def setup(app):
92+
app.add_directive('gdareatable', TableDirective)

_static/css/custom.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,3 +1865,38 @@ p + .classref-constant {
18651865
border: 0px solid #7fbbe3;
18661866
background: var(--role-button-background-color);
18671867
}
1868+
1869+
.rst-content table.docutils.gdarea-table {
1870+
background-color: var(--code-background-color);
1871+
border: 0;
1872+
border-left: 6px solid var(--code-border-color);
1873+
padding: 4px 10px;
1874+
width: 100%;
1875+
table-layout:fixed
1876+
}
1877+
1878+
.rst-content table.docutils.gdarea-table td.gdarea-table-header {
1879+
padding: 8px;
1880+
border-right:1px dashed var(--code-border-color);
1881+
text-align: left;
1882+
width:25%;
1883+
}
1884+
1885+
.rst-content table.docutils.gdarea-table td {
1886+
padding: 8px 0 8px 12px;
1887+
background-color: var(--code-background-color) !important;
1888+
}
1889+
1890+
.rst-content table.docutils.gdarea-table td.gdarea-table-header, .rst-content table.docutils.gdarea-table td {
1891+
border-bottom: 1px dashed var(--code-border-color);
1892+
border-collapse:collapse
1893+
}
1894+
1895+
.rst-content table.docutils.gdarea-table tr:last-of-type td, .rst-content table.docutils.gdarea-table tr:last-of-type td.gdarea-table-header {
1896+
border-bottom:0
1897+
}
1898+
1899+
.rst-content table.docutils.gdarea-table td.gdarea-table-header > p {
1900+
font-size: 1rem !important;
1901+
font-weight: bold;
1902+
}

conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111

1212
# -- General configuration
1313

14+
import sys
15+
import os
16+
sys.path.insert(0, os.path.abspath('./_extensions'))
17+
1418
extensions = [
1519
"sphinx_tabs.tabs",
1620
"notfound.extension",
1721
"sphinxext.opengraph",
1822
"sphinx_copybutton",
1923
"sphinxcontrib.video",
24+
"area_table",
2025
]
2126

2227
intersphinx_mapping = {

0 commit comments

Comments
 (0)