Skip to content

Commit e179634

Browse files
committed
Merging branch/2023-02-02/readthedocs for GitHub pull request #141 <#141>.
2 parents 8a88acd + 170d805 commit e179634

File tree

9 files changed

+228
-35
lines changed

9 files changed

+228
-35
lines changed

.readthedocs.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# .readthedocs.yaml -- Build configuration for MPS manual on Read The Docs
2+
#
3+
# Copyright (c) 2023 Ravenbrook Limited. See end of file for license.
4+
#
5+
# This file controls how Read the Docs builds and publishes the MPS
6+
# manual at <https://memory-pool-system.readthedocs.io/>.
7+
#
8+
# See <https://docs.readthedocs.io/en/stable/config-file/v2.html> for
9+
# the file format.
10+
#
11+
# Project configuration is at
12+
# <https://readthedocs.org/projects/memory-pool-system/>. The GitHub
13+
# Ravenbot user <sysadmins@ravenbrook.com> is an administrator
14+
# <https://readthedocs.org/profiles/Ravenbot/>.
15+
16+
version: 2
17+
18+
build:
19+
os: ubuntu-22.04
20+
tools:
21+
python: '3'
22+
23+
python:
24+
install:
25+
- requirements: manual/requirements.pip
26+
27+
sphinx:
28+
configuration: manual/source/conf.py
29+
30+
# A. REFERENCES
31+
#
32+
# [Readthedocs] "Read the Docs: Documentation Simplified";
33+
# <https://docs.readthedocs.io/en/stable/>.
34+
#
35+
#
36+
# B. DOCUMENT HISTORY
37+
#
38+
# 2023-02-02 RB Created as part of MPS GitHub migration.
39+
#
40+
#
41+
# C. COPYRIGHT AND LICENSE
42+
#
43+
# Copyright © 2023 Ravenbrook Limited <https://www.ravenbrook.com/>.
44+
#
45+
# Redistribution and use in source and binary forms, with or without
46+
# modification, are permitted provided that the following conditions are
47+
# met:
48+
#
49+
# 1. Redistributions of source code must retain the above copyright
50+
# notice, this list of conditions and the following disclaimer.
51+
#
52+
# 2. Redistributions in binary form must reproduce the above copyright
53+
# notice, this list of conditions and the following disclaimer in the
54+
# documentation and/or other materials provided with the distribution.
55+
#
56+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
57+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
58+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
59+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
60+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
62+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
66+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67+
#
68+
#
69+
# $Id$

design/doc.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ _`.impl.design`: Design documents are written in plain RST (with no
9393
custom directives) to meet `.req.design.standalone`_.
9494

9595
_`.impl.design.pelican`: Design documents are converted to HTML using
96-
|RstReader|_.
96+
|RstReader|_ as part of `Charlotte
97+
<https://info.ravenbrook.com/project/charlotte>`__.
9798

9899
.. |RstReader| replace:: ``pelican.readers.RstReader``
99100
.. _RstReader: https://fossies.org/dox/pelican-3.7.1/classpelican_1_1readers_1_1RstReader.html
100101

102+
_`.impl.design.github`: Design documents are also `rendered as HTML by GitHub <https://docs.github.com/en/repositories/working-with-files/using-files/working-with-non-code-files#rendering-differences-in-prose-documents>`__.
103+
101104
_`.impl.manual`: The manual is written in RST using Sphinx_ extensions
102105
and custom manual extensions (see `.ext`_).
103106

@@ -206,18 +209,18 @@ is translated into a ``c:function`` directive::
206209
.. c:function:: void LandFinish(Land land)
207210

208211

209-
_`.fmt.function-decl`: A paragraph consisting of a macro
210-
declaration on a single line formatted as code, for example::
212+
_`.fmt.macro-decl`: A paragraph consisting of a macro declaration on a
213+
single line formatted as code, for example::
211214

212215
``RING_FOR(node, ring, next)``
213216

214217
is translated into a ``c:macro`` directive::
215218

216219
.. c:macro:: RING_FOR(node, ring, next)
217220

218-
Macros are identified by having names consisting of capital letters,
219-
numbers, and underscore, or appearing in the list of exceptions given
220-
by the ``MACROS`` global in designs.py.
221+
_`.fmt.macro`: Macros are identified by having names consisting of
222+
capital letters, numbers, and underscore, or appearing in the list of
223+
exceptions given by the ``MACROS`` global in designs.py.
221224

222225
_`.fmt.type-def`: A paragraph consisting of a type definition on a
223226
single line formatted as code, for example::
@@ -323,14 +326,16 @@ Document History
323326
----------------
324327

325328
- 2018-09-18 GDR_ Created based on [RB_2013-05-09]_.
329+
- 2023-02-15 RB_ Updating for migration to GitHub.
326330

327331
.. _GDR: https://www.ravenbrook.com/consultants/gdr/
332+
.. _RB: mailto:rb@ravenbrook.com
328333

329334

330335
Copyright and License
331336
---------------------
332337

333-
Copyright © 2018–2020 `Ravenbrook Limited <https://www.ravenbrook.com/>`_.
338+
Copyright © 2018–2023 `Ravenbrook Limited <https://www.ravenbrook.com/>`_.
334339

335340
Redistribution and use in source and binary forms, with or without
336341
modification, are permitted provided that the following conditions are

manual/Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Makefile for Sphinx documentation
2+
#
23
# $Id$
4+
#
5+
# Keep consistent with build.txt section on building the MPS manual.
36

47
# You can set these variables from the command line.
8+
PYTHON = python3
59
SPHINXOPTS =
610
SPHINXBUILD = tool/bin/sphinx-build
711
PAPER =
@@ -10,7 +14,7 @@ BUILDDIR = .
1014
# Internal variables.
1115
PAPEROPT_a4 = -D latex_paper_size=a4
1216
PAPEROPT_letter = -D latex_paper_size=letter
13-
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
17+
ALLSPHINXOPTS = -T -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
1418
# the i18n builder cannot share the environment and doctrees with the others
1519
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
1620

@@ -154,12 +158,11 @@ doctest: $(SPHINXBUILD)
154158
@echo "Testing of doctests in the sources finished, look at the " \
155159
"results in $(BUILDDIR)/doctest/output.txt."
156160

157-
tools: tool/bin/sphinx-build
161+
.PHONY: tools
162+
tools: tool/bin/pip requirements.pip
163+
tool/bin/pip install -r requirements.pip
158164

159-
tool/bin/sphinx-build: tool/bin/pip
160-
tool/bin/pip install 'sphinx < 5' # Layout breaks in Sphinx >= 5. See <https://github.com/Ravenbrook/mps/issues/121>.
161-
@echo "You can now use \`make SPHINXBUILD=tool/bin/sphinx-build html' etc."
162-
@echo "Or add tool/bin to your path."
165+
tool/bin/sphinx-build: tools
163166

164167
tool/bin/pip:
165-
python3 -mvenv tool
168+
$(PYTHON) -mvenv tool

manual/build.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Introduction
99
------------
1010

1111
This document describes the various ways in which you can build the MPS,
12-
its libraries, and the tests and tools that come with it.
12+
its manual, its libraries, and the tests and tools that come with it.
1313

1414
You may be building the MPS for a number of different purposes.
1515

@@ -94,6 +94,32 @@ If you want to do anything beyond these simple cases, use the MPS build
9494
as described in the section "Building the MPS for development" below.
9595

9696

97+
Building the MPS manual
98+
-----------------------
99+
100+
Builds of the MPS manual from the main MPS repo should be available at
101+
`<https://memory-pool-system.readthedocs.io/>`_.
102+
103+
If that's not available, or if you have a variant of the MPS Kit, or
104+
are making modifications to the MPS itself, then you should build the
105+
manual for yourself. This uses Sphinx
106+
`<https://www.sphinx-doc.org/>`_.
107+
108+
On Unix-like platforms (including macOS), the Makefile in the manual
109+
directory can fetch and install a local copy of Sphinx and build the
110+
manual, like this::
111+
112+
cd manual
113+
make html
114+
115+
then open manual/html/index.html.
116+
117+
On Windows platforms, follow the `Sphinx installation instructions
118+
<https://www.sphinx-doc.org/en/master/usage/installation.html>`_ for
119+
Windows, then invoke Sphinx as shown in the Makefile in the manual
120+
directory.
121+
122+
97123
Building the MPS for development
98124
--------------------------------
99125

manual/requirements.pip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# manual/requirements.txt -- MPS manual build requirements for pip
2+
3+
# Layout breaks in Sphinx >= 5. See <https://github.com/Ravenbrook/mps/issues/121>.
4+
sphinx >= 4, < 5

manual/source/extensions/mps/designs.py

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# designs.py -- Convert MPS design documents into sources for the MPS manual
2-
# $Id$
32
#
4-
# This was originally done in the Makefile, but moved to Python in the hope
5-
# that readthedocs.org would be able to generate the manual. However, they
6-
# (sensibly) don't run extensions, so we can't use them. Processing the
7-
# designs here still seems like a good idea, though.
3+
# Copyright (c) 2013-2023 Ravenbrook Limited. See end of file for license.
4+
#
5+
# This code converts the MPS design documents (in plain
6+
# reStructuredText) for use in the manual (in Sphinx extended
7+
# reStructuredText) and so implements design.mps.doc.fmt.
88
#
9+
# TODO: It's a shame that the regexps we convert from (near the start
10+
# of the file) are a log way from the strings we convert to (in
11+
# ``convert_file``).
912

1013
from __future__ import unicode_literals
1114

@@ -43,22 +46,43 @@
4346
'''
4447

4548
mode = re.compile(r'\.\. mode: .*\n')
49+
50+
# design.mps.doc.metadata.tag
4651
prefix = re.compile(r'^:Tag: ([a-z][a-z.0-9-]*[a-z0-9])$', re.MULTILINE)
52+
4753
rst_tag = re.compile(r'^:(?:Author|Date|Status|Revision|Copyright|Organization|Format|Index terms|Readership):.*?$\n', re.MULTILINE | re.IGNORECASE)
54+
55+
# design.mps.doc.fmt.tag
4856
mps_tag = re.compile(r'_`\.([a-z][A-Za-z.0-9_-]*[A-Za-z0-9])`:')
57+
58+
# design.mps.doc.fmt.ref
4959
mps_ref = re.compile(r'`(\.[a-z][A-Za-z.0-9_-]*[A-Za-z0-9])`_(?: )?')
60+
61+
# design.mps.doc.fmt.function-decl
5062
funcdef = re.compile(r'^``([^`]*\([^`]*\))``$', re.MULTILINE)
63+
64+
# design.mps.doc.fmt.macro-decl
5165
macrodef = re.compile(r'^``((?:[A-Z][A-Z0-9_]+|{})(?:\([^`]*\))?)``$'
5266
.format('|'.join(map(re.escape, MACROS.split()))), re.MULTILINE)
67+
# design.mps.doc.fmt.macro
5368
macro = re.compile(r'``([A-Z][A-Z0-9_]+)``(?: )?')
69+
70+
# design.mps.doc.fmt.type-def
5471
typedef = re.compile(r'^``typedef ([^`]*)``$', re.MULTILINE)
72+
73+
# design.mps.doc.fmt.function-ref
5574
func = re.compile(r'``([A-Za-z][A-Za-z0-9_]+\(\))``')
75+
76+
# design.mps.doc.fmt.type-ref
5677
typename = re.compile(r'``({0}|[A-Z][A-Za-z0-9_]*'
5778
r'(?:Class|Function|Method|Struct|Union)|'
5879
r'mps_[a-z_]+_[stu])``(?: )?'
5980
.format('|'.join(map(re.escape, TYPES.split()))))
81+
82+
# Tags referencing other design documents
6083
design_ref = re.compile(r'^( *\.\. _design\.mps\.(?:[^:\n]+): (?:[^#:\n]+))$', re.MULTILINE)
6184
design_frag_ref = re.compile(r'^( *\.\. _design\.mps\.([^:\n]+)\.([^:\n]+): (?:[^#:\n]+))#(.+)$', re.MULTILINE)
85+
6286
relative_link = re.compile(r'^( *\.\. _[\w\.]+: +\.\./)', re.MULTILINE)
6387
history = re.compile(r'^Document History\n.*',
6488
re.MULTILINE | re.IGNORECASE | re.DOTALL)
@@ -69,7 +93,9 @@
6993
def secnum_sub(m):
7094
return m.group(1) + '\n' + m.group(3) * len(m.group(1))
7195

72-
# Convert Ravenbrook style citations into MPS Manual style citations.
96+
# Convert Ravenbrook style citations into MPS Manual style citations
97+
# (design.mps.doc.fmt.citation)
98+
#
7399
# Example citations transformation, from:
74100
# .. [THVV_1995] "Structure Marking"; Tom Van Vleck; 1995;
75101
# <http://www.multicians.org/thvv/marking.html>.
@@ -157,18 +183,66 @@ def newer(src, target):
157183
logger = logging.getLogger(__name__)
158184

159185
# Mini-make
186+
#
187+
# This uses app.srcdir (the directory of the manual sources) to find
188+
# the root of the MPS tree (two directories above) and so find the
189+
# design documents to convert.
190+
160191
def convert_updated(app):
161192
logger.info(bold('converting MPS design documents'))
162-
for design in glob.iglob('../design/*.txt'):
193+
for design in glob.iglob(os.path.join(app.srcdir, '../../design/*.txt')):
163194
name = os.path.splitext(os.path.basename(design))[0]
164195
if name == 'index': continue
165-
converted = 'source/design/%s.rst' % name
196+
converted = os.path.join(app.srcdir, 'design/%s.rst' % name)
166197
if newer(design, converted):
167198
logger.info('converting design %s' % name)
168199
convert_file(name, design, converted)
169-
diagrams = chain(*[glob.iglob('../design/*.' + ext)
200+
diagrams = chain(*[glob.iglob(os.path.join(app.srcdir, '../../design/*.' + ext))
170201
for ext in 'png svg'.split()])
171202
for diagram in diagrams:
172-
target = os.path.join('source/design/', os.path.basename(diagram))
203+
target = os.path.join(app.srcdir, 'design/', os.path.basename(diagram))
173204
if newer(diagram, target):
174205
shutil.copyfile(diagram, target)
206+
207+
208+
# A. REFERENCES
209+
#
210+
# [GDR-2018-09-18] "Documentation"; Gareth Rees; 2018-09-18; design.mps.doc.
211+
#
212+
#
213+
# B. DOCUMENT HISTORY
214+
#
215+
# 2013-06-01 RB Created.
216+
# 2023-02-15 RB Updated with copyright, licence, and document history.
217+
#
218+
#
219+
# C. COPYRIGHT AND LICENSE
220+
#
221+
# Copyright (C) 2023 Ravenbrook Limited <https://www.ravenbrook.com/>.
222+
#
223+
# Redistribution and use in source and binary forms, with or without
224+
# modification, are permitted provided that the following conditions are
225+
# met:
226+
#
227+
# 1. Redistributions of source code must retain the above copyright
228+
# notice, this list of conditions and the following disclaimer.
229+
#
230+
# 2. Redistributions in binary form must reproduce the above copyright
231+
# notice, this list of conditions and the following disclaimer in the
232+
# documentation and/or other materials provided with the
233+
# distribution.
234+
#
235+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
236+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
237+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
238+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
239+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
240+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
241+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
243+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
244+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
245+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
246+
#
247+
#
248+
# $Id$

manual/source/guide/overview.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
Overview of the Memory Pool System
99
==================================
1010

11+
.. IMPORTANT: If you change the paragraph below, also change
12+
readme.txt
13+
1114
The Memory Pool System is a very general, adaptable, flexible,
1215
reliable, and efficient memory management system. It permits the
1316
flexible combination of memory management techniques, supporting

0 commit comments

Comments
 (0)