Skip to content

Commit

Permalink
docs: Copy edits for line wrapping and column widths
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Aug 8, 2024
1 parent 3b86cda commit 7a88b60
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 38 deletions.
15 changes: 9 additions & 6 deletions docs/python/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ Review the broken links in the ``_linkcheck/output.txt`` file:
.. _readthedocs:

Create a ReadTheDocs project
----------------------------
ReadTheDocs
-----------

Create a project
~~~~~~~~~~~~~~~~

#. Sign in to `ReadTheDocs <https://readthedocs.org/dashboard/>`__
#. Click *Import a Project*
Expand Down Expand Up @@ -133,8 +136,8 @@ Create a ReadTheDocs project
#. Uncheck *Active*
#. Click *Save*

Configure the ReadTheDocs project
---------------------------------
Configure the project
~~~~~~~~~~~~~~~~~~~~~

.. tab-set::

Expand All @@ -160,8 +163,8 @@ Configure the ReadTheDocs project

At present, Python 3.9 is used, because ReadTheDocs is not compatible with Python 3.10.

Redirect a ReadTheDocs project
------------------------------
Redirect a project
~~~~~~~~~~~~~~~~~~

#. Replace ``docs/_templates/layout.html`` with the below, replacing ``SUBDOMAIN``:

Expand Down
42 changes: 17 additions & 25 deletions docs/python/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See `Adding resources in bulk <https://developers.transifex.com/docs/cli#adding-

For reference, the equivalent with the old Python Transifex Client, replacing ``TXPROJECT`` and ``APP``, was:

.. code:: bash
.. code-block:: bash
tx config mapping -r TXPROJECT.django -f APP/locale/en_US/LC_MESSAGES/django.po -s en_US -t PO 'APP/locale/<lang>/LC_MESSAGES/django.po'
Expand All @@ -46,54 +46,46 @@ Translate with Transifex

Whenever text in the interface is added or updated, you must extract the strings to translate from the code files into PO files by running:

.. grid:: 2
.. code-block:: bash
:caption: Django
.. grid-item-card:: Django
django-admin makemessages -l en_US --no-obsolete
.. code:: bash
.. code-block:: bash
:caption: Python (example)
django-admin makemessages -l en_US --no-obsolete
.. grid-item-card:: Python (example)

.. code:: bash
pybabel extract -F babel.cfg -o messages.pot .
pybabel update -i messages.pot -d locale
pybabel extract -F babel.cfg -o messages.pot .
pybabel update -i messages.pot -d locale
Then, push the PO files to Transifex with:

.. code:: bash
.. code-block:: bash
tx push -s
If you made local changes to translations, push the translations to Transifex. For example:

.. code:: bash
.. code-block:: bash
tx push -t -l en
When ready, pull the translations from Transifex with:

.. code:: bash
.. code-block:: bash
tx pull -f -a
Then, compile the PO files to MO files with:

.. grid:: 2

.. grid-item-card:: Django

.. code:: bash
python manage.py compilemessages
.. code-block:: bash
:caption: Django
.. grid-item-card:: Python (example)
python manage.py compilemessages
.. code:: bash
.. code-block:: bash
:caption: Python (example)
pybabel compile -f -d locale
pybabel compile -f -d locale
Reference: Django `Translation <https://docs.djangoproject.com/en/4.2/topics/i18n/translation/>`__

Expand Down
4 changes: 2 additions & 2 deletions docs/python/style_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ Warnings

The `warnings.catch_warnings(record=True) <https://docs.python.org/3/library/warnings.html#warnings.catch_warnings>`__ context manager catches instances of ``warnings.WarningMessage``, not instances of the original warning classes. To reissue a warning, you need to do, like in `Apache Airflow <https://github.com/apache/airflow/blob/main/airflow/utils/warnings.py>`__:

.. code:: python
.. code-block:: python
warnings.warn_explicit(w.message, w.category, w.filename, w.lineno, source=w.source)
The `warnings.warn_explicit() <https://docs.python.org/3/library/warnings.html#warnings.warn_explicit>`__ function calls `category(message) <https://github.com/python/cpython/blob/v3.10.0/Lib/warnings.py#L345>`__. If the ``_init__`` method is overridden with additional required arguments, a ``TypeError`` is raised, like ``MyWarning.__init__() missing 2 required positional arguments``.

Because the additional required arguments are unavailable, you can't do:

.. code:: python
.. code-block:: python
warnings.warn(category(w.message, var1, var2)) # var1 and var2 are indeterminable
Expand Down
17 changes: 12 additions & 5 deletions docs/rust/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Preferences

.. Candidates for preferences https://github.com/open-contracting/cardinal-rs/issues/4
Performance
-----------

.. seealso::

`coz <https://github.com/plasma-umass/coz>`__ profiler

Code style
----------

Expand Down Expand Up @@ -151,14 +158,14 @@ If you're getting confusing compile errors, especially any involving type annota
- Your annotations are correct. If you change your code but don't change your annotations, the compiler might report errors that are distantly related to the misannotation.
- You duck type using trait objects: for example, ``Box<dyn Read>`` to use ``std::io:stdin()`` and ``File::open(file).unwrap()`` interchangeably. The compiler can't determine which traits are relevant across the two types.

If errors relate to ownership, try:
If errors relate to ownership, try using:

- Using ``Arc<Mutex<T>>``, as discussed in sections `16.3 <https://doc.rust-lang.org/book/ch16-03-shared-state.html#atomic-reference-counting-with-arct>`__ and `20.2 <https://doc.rust-lang.org/book/ch20-02-multithreaded.html#sending-requests-to-threads-via-channels>`__ of *The Rust Programming Language*.
- Using ``Option`` with ``take()``, as discussed in sections `17.3 <https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html#requesting-a-review-of-the-post-changes-its-state>`__ and `20.3 <https://doc.rust-lang.org/book/ch20-03-graceful-shutdown-and-cleanup.html#implementing-the-drop-trait-on-threadpool>`__ of *The Rust Programming Language*.
- ``Arc<Mutex<T>>``, as discussed in sections `16.3 <https://doc.rust-lang.org/book/ch16-03-shared-state.html#atomic-reference-counting-with-arct>`__ and `20.2 <https://doc.rust-lang.org/book/ch20-02-multithreaded.html#sending-requests-to-threads-via-channels>`__ of *The Rust Programming Language*.
- ``Option`` with ``take()``, as discussed in sections `17.3 <https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html#requesting-a-review-of-the-post-changes-its-state>`__ and `20.3 <https://doc.rust-lang.org/book/ch20-03-graceful-shutdown-and-cleanup.html#implementing-the-drop-trait-on-threadpool>`__ of *The Rust Programming Language*.

To reduce the number of allocations, try:
To reduce the number of allocations, try using:

- Using ``mem::take`` or ``mem::replace`` (`Rust Design Patterns <https://rust-unofficial.github.io/patterns/idioms/mem-replace.html>`__).
- ``mem::take`` or ``mem::replace`` (`Rust Design Patterns <https://rust-unofficial.github.io/patterns/idioms/mem-replace.html>`__).

.. seealso::

Expand Down

0 comments on commit 7a88b60

Please sign in to comment.