Skip to content

Commit 6c474c5

Browse files
committed
Add RFCs into the website
1 parent 08ffa2f commit 6c474c5

File tree

6 files changed

+82
-36
lines changed

6 files changed

+82
-36
lines changed

.github/workflows/publish-pages.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: deploy_sphinx
42

53
permissions:
64
id-token: write
75
pages: write
86

9-
# Controls when the workflow will run
107
on:
11-
# Triggers the workflow on push or pull request events but only for the "master" branch
128
push:
139
branches: [ "master" ]
1410
# dispatch from the main repo, needs PAT with access to both repos
@@ -21,17 +17,16 @@ jobs:
2117
build:
2218
runs-on: ubuntu-latest
2319
steps:
24-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2520
- uses: actions/checkout@v4
2621
- name: Checkout spec repo
2722
uses: actions/checkout@v4
2823
with:
2924
repository: SampleEnvironment/SECoP
3025
path: ./SECoP
31-
- name: copy spec into correct folder
26+
- name: copy over spec
3227
run: cp -r ./SECoP/protocol/specification/* source/specification
33-
- name: copy 1-0 spec into correct folder
34-
run: cp ./SECoP/protocol/SECoP_Specification_V1.0.rst source/specification/SECoP_Specification_V1.0.rst
28+
- name: process rfcs
29+
run: python process_rfcs.py ./SECoP/rfcs source/rfcs
3530
- name: Import secop-img SVGs
3631
uses: robinraju/[email protected]
3732
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build/
22
.venv/
33
__pycache__/
4+
source/rfcs/[0-9]*

process_rfcs.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import pathlib
2+
import sys
3+
4+
sourcedir = pathlib.Path(sys.argv[1])
5+
destdir = pathlib.Path(sys.argv[2])
6+
7+
rfcs = []
8+
9+
for rfc in sourcedir.glob('RFC-*.rst'):
10+
if rfc.name.startswith('RFC-000'):
11+
continue
12+
13+
n = rfc.name.split('-')[1]
14+
15+
with open(rfc, 'r', encoding='utf-8') as f:
16+
lines = f.readlines()
17+
18+
assert lines[0].startswith('- Feature: ')
19+
raw_title = lines[0][10:].strip()
20+
title = f'RFC {n}: {raw_title}'
21+
assert lines[1].startswith('- Status: ')
22+
status = lines[1][10:].strip()
23+
lines[:1] = [
24+
'.. _rfc-' + n + ':\n',
25+
'\n',
26+
title + '\n',
27+
'@' * len(title) + '\n',
28+
'\n',
29+
]
30+
31+
new_name = rfc.name.removeprefix('RFC-')
32+
33+
dest_file = destdir / new_name
34+
with open(dest_file, 'w', encoding='utf-8') as f:
35+
f.writelines(lines)
36+
37+
rfcs.append((new_name.removesuffix('.rst'), n, raw_title, status))
38+
39+
rfcs.sort()
40+
41+
with open(destdir / 'index.rst', 'r', encoding='utf-8') as f:
42+
lines = f.readlines()
43+
44+
with open(destdir / 'index.rst', 'w', encoding='utf-8') as f:
45+
for line in lines:
46+
if line.strip() == '.. toctree::':
47+
f.write(line)
48+
f.write(' :maxdepth: 1\n')
49+
f.write(' :hidden:\n\n')
50+
for ref in rfcs:
51+
f.write(f' {ref[0]}\n')
52+
53+
f.write('\n')
54+
f.write('.. list-table::\n')
55+
f.write(' :widths: 10 70 20\n')
56+
f.write(' :header-rows: 1\n\n')
57+
f.write(' * - #\n')
58+
f.write(' - Title\n')
59+
f.write(' - Status\n')
60+
for ref, n, title, status in rfcs:
61+
f.write(f' * - {n}\n')
62+
f.write(f' - :ref:`{title} <rfc-{n}>`\n')
63+
f.write(f' - {status}\n')
64+
65+
break
66+
67+
f.write(line)

secop_sphinx.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import re
22

3-
from docutils import nodes
4-
53
from sphinx import addnodes
64
from sphinx.domains.python import PyFunction, PyVariable, PyObject, PyClasslike
7-
from sphinx.util.docutils import ReferenceRole
8-
from sphinx.util.nodes import split_explicit_title
9-
10-
REPO_BASE = 'https://github.com/SampleEnvironment/SECoP/blob/master/'
115

126

137
class Property(PyVariable):
@@ -105,27 +99,6 @@ def get_index_text(self, modname, name_cls):
10599
return '%s (protocol message)' % name_cls[0]
106100

107101

108-
class SecopRFC(ReferenceRole):
109-
def run(self):
110-
target_id = 'index-%s' % self.env.new_serialno('index')
111-
entries = [('single', 'SECoP RFC; RFC %s' % self.target,
112-
target_id, '', None)]
113-
114-
index = addnodes.index(entries=entries)
115-
target = nodes.target('', '', ids=[target_id])
116-
self.inliner.document.note_explicit_target(target)
117-
118-
refuri = REPO_BASE + f'rfcs/RFC-{self.target}.rst'
119-
reference = nodes.reference('', '', internal=False, refuri=refuri)
120-
if self.has_explicit_title:
121-
reference += nodes.strong(self.title, self.title)
122-
else:
123-
num = self.target.split('-')[0]
124-
title = f'SECoP RFC {num}'
125-
reference += nodes.strong(title, title)
126-
return [index, target, reference], []
127-
128-
129102
def setup(app):
130103
app.add_directive('node-property', Property)
131104
app.add_directive('mod-property', Property)
@@ -137,5 +110,4 @@ def setup(app):
137110
app.add_directive('feature', Feature)
138111
app.add_directive('message', Message)
139112
app.add_directive('errorclass', ErrorClass)
140-
app.add_role('secop-rfc', SecopRFC())
141113
return {'parallel_read_safe': True, 'version': '0.1.0'}

source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Welcome to SECoP!
1313
specification/index
1414
howtos/index
1515
implementations/index
16+
rfcs/index
1617
contact
1718
ISSE <https://sampleenvironment.org/>
1819
privacy-policy

source/rfcs/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SECoP RFCs
2+
==========
3+
4+
RFCs are the primary mechanism for further development of SECoP. Everyone in
5+
the community is welcome to create a new RFC for the committee to discuss, see
6+
:ref:`rfc-001` for details.
7+
8+
.. toctree::
9+
10+
.. Everything else in here is automatically generated by ``process_rfcs.py``.

0 commit comments

Comments
 (0)