Skip to content

Commit bfdc54f

Browse files
authored
Documentation copy-editing + some fixes (#1461)
* use `` in places where bare ` were used previously * fix missing references and other sphinx errors * change json code-blocks to use comments to indicate the types of things * updated some docs that referred to unsupported installation methods * remove link to distutils, and fix old setuptools link * rename "target directory" to "installation directory"
1 parent a22f39c commit bfdc54f

10 files changed

+100
-81
lines changed

docs/API.rst

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,108 +15,123 @@ All the log-in methods and restrictions that apply to normal ContestWebServer
1515
usage also apply for API usage. In particular, this implies that IP autologin,
1616
if configured, can be used for API calls.
1717

18-
Otherwise, making a `POST` request to the `/api/login` endpoint, passing
19-
`username` and `password` as form data (as is done for regular login), will
18+
Otherwise, making a ``POST`` request to the ``/api/login`` endpoint, passing
19+
``username`` and ``password`` as form data (as is done for regular login), will
2020
return a JSON object with the following structure:
2121

2222
.. sourcecode:: json
2323

24-
{"login_data": "string"}
24+
{"login_data": /* string */ }
2525
2626
The content of the returned login data string should be passed to API calls
27-
that require authentication in a `X-CMS-Authorization` header.
27+
that require authentication in a ``X-CMS-Authorization`` header.
2828

2929
All other API methods described here require authentication.
3030

3131
Task list
3232
=========
3333

34-
An authenticated `GET` request to `/api/task_list`, done while the contest is
35-
running, will return the following object:
34+
An authenticated ``GET`` request to ``/api/task_list``, done while the contest
35+
is running, will return the following object:
3636

3737
.. sourcecode:: json
3838

39-
{"tasks": [{"name": "string", "statements": ["string"], "submission_format": ["string"] }]}
39+
{
40+
"tasks": [
41+
{
42+
"name": /* string */,
43+
"statements": [/* strings */],
44+
"submission_format": [/* strings */]
45+
}
46+
]
47+
}
4048
4149

42-
Tasks are ordered in the same order as in the UI. The `name` of the task is
43-
used for additional task-specific API calls. `statements` contains a list of
44-
languages for which a statement is available. `submission_format` contains a
50+
Tasks are ordered in the same order as in the UI. The ``name`` of the task is
51+
used for additional task-specific API calls. ``statements`` contains a list of
52+
languages for which a statement is available. ``submission_format`` contains a
4553
list of files that will need to be submitted, where filenames containing the
46-
`%l` string represent source files (that will be compiled and run on the
54+
``%l`` string represent source files (that will be compiled and run on the
4755
server), and all other filenames represent output files.
4856

4957
Submit
5058
======
5159

52-
An authenticated `POST` request to `/api/{taskname}/submit` will send a
60+
An authenticated ``POST`` request to ``/api/{taskname}/submit`` will send a
5361
submission. Files should be provided (according to the submission format) as
5462
form data, with field names matching the submission format.
5563

5664
The request will return an object with the ID of the new submission:
5765

5866
.. sourcecode:: json
5967

60-
{"id": "string"}
68+
{"id": /* string */}
6169
6270

6371
List submissions
6472
================
6573

66-
An authenticated `GET` request to `/api/{taskname}/submission_list` will return
67-
an object describing all the submission done so far on the given task, in
68-
chronological order:
74+
An authenticated ``GET`` request to ``/api/{taskname}/submission_list`` will
75+
return an object describing all the submission done so far on the given task,
76+
in chronological order:
6977

7078
.. sourcecode:: json
7179

72-
{"list": [{"id": "string"}]}
80+
{
81+
"list": [
82+
{ "id": /* string */ }
83+
]
84+
}
7385
7486
Task statement
7587
==============
7688

7789
A PDF version of the task statement for a given language can be retrieved by
78-
making an authenticated `GET` request to `tasks/{taskname}/statements/{lang}`.
90+
making an authenticated ``GET`` request to
91+
``tasks/{taskname}/statements/{lang}``.
7992

8093
Scoring information
8194
===================
8295

83-
An authenticated `GET` request to `/tasks/{taskname}/submissions/{id}` will
84-
retrieve information on the submission with the given `id`. In particular,
85-
its field `public_score` will contain the score of this submission, and
86-
`task_public_score` will contain the current score for the task.
96+
An authenticated ``GET`` request to ``/tasks/{taskname}/submissions/{id}`` will
97+
retrieve information on the submission with the given ``id``. In particular,
98+
its field ``public_score`` will contain the score of this submission, and
99+
``task_public_score`` will contain the current score for the task.
87100

88101
Additional details on the submission's results can be retrieved by making an
89-
authenticated `GET` request to `/tasks/{taskname}/submissions/{id}/details`.
102+
authenticated ``GET`` request to ``/tasks/{taskname}/submissions/{id}/details``.
90103
The endpoint will return an HTML snippet matching what is seen by contestants.
91104

92105
Impersonation of users
93106
======================
94107

95108
Administrators may impersonate a user and perform requests on their behalf.
96109

97-
This is accomplished by using the authentication endpoint without `password`
98-
and with an additional `admin_token` parameter equal to the `contest_admin_token`
99-
from the CMS configuration. The returned authentication token refers to the
100-
given user, but it is marked as impersonated.
110+
This is accomplished by using the authentication endpoint without ``password``
111+
and with an additional ``admin_token`` parameter equal to the
112+
``contest_admin_token`` from the CMS configuration. The returned authentication
113+
token refers to the given user, but it is marked as impersonated.
101114

102-
Requests carrying an impersonated authentication token may bypass certain restrictions:
115+
Requests carrying an impersonated authentication token may bypass certain
116+
restrictions:
103117

104118
* IP-based login restrictions do no apply. (But if IP-based autologin is set,
105119
it overrides all authentication tokens including impersonated ones.)
106120

107121
* Hidden participation is never blocked.
108122

109-
* Requests can carry special parameters (either in the URL or in `POST` data)
123+
* Requests can carry special parameters (either in the URL or in ``POST`` data)
110124
that bypasses further restrictions when set to ``1``:
111125

112-
* `override_phase_check` lets the operation proceed regardless of contest phase
113-
(for example, you can submit even though the contest has already ended).
126+
* ``override_phase_check`` lets the operation proceed regardless of contest
127+
phase (for example, you can submit even though the contest has already
128+
ended).
114129

115-
* `override_official` (in the submit endpoint) makes the submission count as
116-
official regardless of contest phase.
130+
* ``override_official`` (in the submit endpoint) makes the submission count
131+
as official regardless of contest phase.
117132

118-
* `override_max_number` (in the submit endpoint) skips all checks for the
133+
* ``override_max_number`` (in the submit endpoint) skips all checks for the
119134
maximum number of submits.
120135

121-
* `override_min_interval` (in the submit endpoint) skips all checks for the
122-
minimum time interval between submits.
136+
* ``override_min_interval`` (in the submit endpoint) skips all checks for
137+
the minimum time interval between submits.

docs/Docker image.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ dependencies. We also provide:
99
spawn a volatile database (not persisted on disk) as well as a CMS instance
1010
that automatically runs all unit tests and functional tests.
1111

12-
* :gh_blob:`docker/cms-stresstest.sh`: Similar to `cms_test.sh` but runs the stress
12+
* :gh_blob:`docker/cms-stresstest.sh`: Similar to ``cms_test.sh`` but runs the stress
1313
tests instead of the unit tests. The stress test consists of: creating a
1414
database, populating it with some sample tasks, and then simulating some
1515
users logging in via ContestWebServer and repeatedly performing actions
1616
such as download task statements and submitting solutions.
1717

1818
* :gh_blob:`docker/cms-dev.sh`: This file uses :gh_blob:`docker/docker-compose.dev.yml` to
1919
spawn a database (**persisted** in the local ``.dev/postgres-data`` folder
20-
within the repository) as well as a CMS container that only runs `bash`,
20+
within the repository) as well as a CMS container that only runs ``bash``,
2121
leaving you with a shell from where you can start cms services. Changes
2222
made in the repository are also reflected directly inside the container
2323
(the source code is mounted as a docker volume). The DB port and CMS server
@@ -60,7 +60,7 @@ is similar to:
6060
script uses the **name of the current git branch** and passes it to ``-p``.
6161

6262
Note also that if you are not part of the ``docker`` group then you'll need
63-
to run every docker command with ``sudo``, including ``sudo docker//cms-test.sh``.
63+
to run every docker command with ``sudo``, including ``sudo docker/cms-test.sh``.
6464
We recommend adding yourself to the ``docker`` group.
6565

6666
What the ``docker/cms-test.sh`` command does is: first build a fresh CMS image when

docs/External contest formats.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ As for the second set of needs, the philosophy is that CMS should not force upon
1919
At the moment, CMS comes with two loaders pre-installed:
2020

2121
* :file:`italy_yaml`, for tasks/users stored in the "Italian Olympiad" format.
22-
* :file:`polygon_xml`, for tasks made with `Polygon <https://polygon.codeforces.com/>`_.
22+
* :file:`polygon_xml`, for tasks made with `Polygon <https://polygon.codeforces.com/>`__.
2323

2424
The first one is not particularly suited for general use (see below for more details), so, if you don't want to migrate to one of the aforementioned formats then we encourage you to **write a loader** for your favorite format and then get in touch with CMS authors to have it accepted in CMS. See the file :gh_blob:`cmscontrib/loaders/base_loader.py` for some hints.
2525

@@ -171,7 +171,7 @@ The following are optional keys that must be present for some task type or score
171171
Polygon format
172172
==============
173173

174-
`Polygon <https://polygon.codeforces.com>`_ is a popular platform for the creation of tasks, and a task format, used among others by Codeforces.
174+
`Polygon <https://polygon.codeforces.com>`__ is a popular platform for the creation of tasks, and a task format, used among others by Codeforces.
175175

176176
Since Polygon doesn't support CMS directly, some task parameters cannot be set using the standard Polygon configuration. The importer reads from an optional file :file:`cms_conf.py` additional configuration specifics to CMS. Additionally, user can add file named contestants.txt to allow importing some set of users.
177177

docs/Installation.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ On Ubuntu 24.04, one will need to run the following script as root to satisfy al
8181
apt install nginx-full php-cli texlive-latex-base \
8282
a2ps ghc rustc mono-mcs pypy3
8383

84-
The above commands provide a very essential Pascal environment. Consider installing the following packages for additional units: `fp-units-base`, `fp-units-fcl`, `fp-units-misc`, `fp-units-math` and `fp-units-rtl`.
84+
The above commands provide a very essential Pascal environment. Consider installing the following packages for additional units: ``fp-units-base``, ``fp-units-fcl``, ``fp-units-misc``, ``fp-units-math`` and ``fp-units-rtl``.
8585

8686
Arch Linux
8787
----------
@@ -130,10 +130,10 @@ First obtain the source code of CMS. Download :gh_download:`CMS release`
130130
Alternatively, if you like living at the bleeding edge, check out the CMS
131131
`Git repository <https://github.com/cms-dev/cms>`_ instead.
132132

133-
The preferred method of installation is using :samp:`./install.py --dir={target} cms`,
133+
The preferred method of installation is using :samp:`./install.py --dir={install_dir} cms`,
134134
which does the following:
135135

136-
* Creates a *target directory* of the given name. It contains a Python
136+
* Creates an *installation directory* of the given name. It contains a Python
137137
virtual environment and subdirectories where CMS stores its data, logs, and caches.
138138
If you omit the ``--dir`` option, CMS is installed to ``~/cms`` (``cms`` in the
139139
home directory of the current user). Make sure that it is different from the
@@ -143,25 +143,25 @@ which does the following:
143143

144144
* Checks that Isolate is available.
145145

146-
* Installs the sample configuration files to :samp:`{target}/etc/cms.toml`
147-
and :samp:`{target}/etc/cms_ranking.toml`.
146+
* Installs the sample configuration files to :samp:`{install_dir}/etc/cms.toml`
147+
and :samp:`{install_dir}/etc/cms_ranking.toml`.
148148

149-
Now you can run CMS commands from the shell directly as :samp:`{target}/bin/{command}`.
149+
Now you can run CMS commands from the shell directly as :samp:`{install_dir}/bin/{command}`.
150150
It is usually more convenient to activate the virtual environment, which adds
151-
:samp:`{target}/bin` to your ``$PATH``. This can be done by adding the following line
151+
:samp:`{install_dir}/bin` to your ``$PATH``. This can be done by adding the following line
152152
to your ``~/.profile``:
153153

154154
.. sourcecode:: bash
155155

156156
source $TARGET/bin/activate
157157

158-
(with ``$TARGET`` replaced by the path to your target directory).
158+
(with ``$TARGET`` replaced by the path to your installation directory).
159159

160160

161161
Development installs
162162
--------------------
163163

164-
If you want to develop CMS, you can use :samp:`./install.py --dir={target} cms --devel --editable`.
164+
If you want to develop CMS, you can use :samp:`./install.py --dir={install_dir} cms --devel --editable`.
165165
This includes development dependencies. It also makes the installation linked to the
166166
source directory, so you don't need to reinstall if you edit the source.
167167

@@ -180,6 +180,8 @@ and running the ``isolate-check-environment`` command which checks your system
180180
for common issues.
181181

182182

183+
.. _installation_updatingcms:
184+
183185
Updating CMS
184186
============
185187

docs/Internals.rst

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ lines inside string represented in the JSON have to be escaped
2727
anyway).
2828

2929
An RPC request must be of the form (it is pretty printed here, but it
30-
is sent in compact form inside CMS)::
30+
is sent in compact form inside CMS):
3131

32-
{
33-
"__method": <name of the requested method>,
34-
"__data": {
35-
<name of first arg>: <value of first arg>,
36-
...
37-
},
38-
"__id": <random ID string>
39-
}
32+
.. sourcecode:: json
33+
34+
{
35+
"__method": /* name of the requested method */,
36+
"__data": {
37+
/* name of first arg */: /* value of first arg */,
38+
/* ... */
39+
},
40+
"__id": /* random ID string */
41+
}
4042
4143
The arguments in ``__data`` are (of course) not ordered: they have to
4244
be matched according to their names. In particular, this means that
@@ -47,13 +49,15 @@ The ``__id`` is a random string that will be returned in the response,
4749
and it is useful (actually, it's the only way) to match requests with
4850
responses.
4951

50-
The response is of the form::
52+
The response is of the form:
53+
54+
.. sourcecode:: json
5155

52-
{
53-
"__data": <return value or null>,
54-
"__error": <null or error string>,
55-
"__id": <random ID string>
56-
}
56+
{
57+
"__data": /* return value or null */,
58+
"__error": /* null or error string */,
59+
"__id": /* random ID string */
60+
}
5761
5862
The value of ``__id`` must of course be the same as in the request.
5963
If ``__error`` is not null, then ``__data`` is expected to be null.
@@ -65,7 +69,7 @@ Setting the ``backdoor`` configuration key to true causes services to
6569
serve a Python console (accessible with netcat), running in the same
6670
interpreter instance as the service, allowing to inspect and modify its
6771
data, live. It will be bound to a local UNIX domain socket, usually at
68-
:file:`{target}/run/{service}_{shard}`.
72+
:file:`{install_dir}/run/{service}_{shard}`.
6973
Although there's no authentication mechanism to prevent unauthorized
7074
access, the socket is accessible only to the ``cmsuser``, which should
7175
make it safe to run the backdoor everywhere, even on workers that are

docs/RankingWebServer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RWS doesn't use the PostgreSQL database. Instead, it stores its data in :file:`/
5252

5353
The intended way to get data to RWS is to have the rest of CMS send it. The service responsible for that is ProxyService (PS for short). When PS is started for a certain contest, it will send the data for that contest to all RWSs it knows about (i.e. those in its configuration). This data includes the contest itself (its name, its begin and end times, etc.), its tasks, its users and teams, and the submissions received so far. Then it will continue to send new submissions as soon as they are scored and it will update them as needed (for example when a user uses a token). Note that hidden users (and their submissions) will not be sent to RWS.
5454

55-
There are also other ways to insert data into RWS: send custom HTTP requests or directly write JSON files. For the former, the script `cmsRWSHelper` can be used to handle the low level communication.
55+
There are also other ways to insert data into RWS: send custom HTTP requests or directly write JSON files. For the former, the script ``cmsRWSHelper`` can be used to handle the low level communication.
5656

5757
Logo, flags and faces
5858
---------------------

docs/Running CMS.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Finally you have to create the database schema for CMS, by running:
5151
Configuring CMS
5252
===============
5353

54-
There are two configuration files, one for CMS itself and one for the rankings. Samples for both files are in the directory :gh_tree:`config/`. You want to copy them to the same file names but without the ``.sample`` suffix (that is, to :file:`config/cms.toml` and :file:`config/cms_ranking.toml`) before modifying them.
54+
There are two configuration files, one for CMS itself and one for the rankings. Samples for both files are in the directory :gh_tree:`config/`. To modify them, first install CMS (using, for example, ``./install.py cms``) and then modify the files in :samp:`{install_dir}/etc/`.
5555

5656
* :file:`cms.toml` is intended to be the same on all machines; all configurations options are explained in the file; of particular importance is the definition of ``core_services``, that specifies where and how many services are going to be run, and the connecting line for the database, in which you need to specify the name of the user created above and its password.
5757

@@ -69,12 +69,10 @@ If you are organizing a real contest, you must also change ``secret_key`` to a r
6969

7070
As the name implies, the value of ``secret_key`` must be kept confidential. If a contestant knows it (for example because you are using the default value), they may be easily able to log in as another contestant.
7171

72-
The configuration files get copied automatically by the ``prerequisites.py`` script, so you can either run ``sudo ./prerequisites.py install`` again (answering "Y" when questioned about overwriting old configuration files) or you could simply edit the previously installed configuration files (which are usually found in ``/usr/local/etc/`` or ``/etc/``), if you do not plan on running that command ever again.
73-
7472
Running CMS
7573
===========
7674

77-
Here we will assume you installed CMS. If not, you should replace all commands path with the appropriate local versions (for example, ``cmsLogService`` becomes :gh_blob:`./scripts/cmsLogService`).
75+
You must install CMS (using, for example, ``./install.py cms``) before continuing. Note that if you didn't activate CMS's virtual environment, you need to prefix all commands with :samp:`{install_dir}/bin/`.
7876

7977
At this point, you should have CMS installed on all the machines you want run services on, with the same configuration file, and a running PostgreSQL instance. To run CMS, you need a contest in the database. To create a contest, follow :doc:`these instructions <Creating a contest>`.
8078

@@ -106,7 +104,7 @@ You should now be able to start exploring the admin interface, by default at htt
106104

107105
cmsAddAdmin name
108106

109-
CMS will create an admin account with username "name" and a random password that will be printed by the command. You can log in with this credentials, and then use the admin interface to modify the account or add other accounts.
107+
CMS will create an admin account with username "name" and a random password that will be printed by the command. You can log in with these credentials, and then use the admin interface to modify the account or add other accounts.
110108

111109
.. _running-cms_recommended-setup:
112110

@@ -117,8 +115,8 @@ Starting CMS by systemd
117115
If your system runs ``systemd``, you can start parts of CMS as systemd services.
118116
They are usually managed by the user instance of systemd for the ``cmsuser`` account.
119117

120-
:samp:`./install.py --dir={target} systemd` installs the following services under
121-
``~/.config/systemd/user/``:
118+
:samp:`./install.py --dir={install_dir} systemd` installs the following
119+
services under ``~/.config/systemd/user/``:
122120

123121
* ``cms-logging.service`` that starts the ``cmsLogService``.
124122

0 commit comments

Comments
 (0)