Skip to content

Commit

Permalink
docs: clarify the syntax of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ned Batchelder committed Jul 19, 2023
1 parent fc2ee98 commit 5dafcc5
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Configuration
#############

.. highlight:: ini

Scriv tries hard to be adaptable to your project's needs. Many aspects of its
behavior can be customized with a settings file.

Expand Down Expand Up @@ -30,6 +32,20 @@ All of the possible files will be read, and settings will cascade. So for
example, setup.cfg can set the fragment directory to "scriv.d", then
"scriv.d/scriv.ini" will be read.

The settings examples here show .ini syntax. If you are using a pyproject.toml
file for settings, you will need to adjust for TOML syntax. This .ini
example::

[scriv]
version = literal: pyproject.toml: project.version

would become:

.. code-block:: toml
[tool.scriv]
version = "literal: pyproject.toml: project.version"
Settings Syntax
===============
Expand Down Expand Up @@ -57,7 +73,7 @@ Scriv provides two built-in templates:
import textwrap
def include_file(fname):
"""Include a source file into the docs as a code block."""
print(".. code::\n")
print(".. code-block:: jinja\n")
with open(fname) as f:
print(textwrap.indent(f.read(), prefix=" "))
.. ]]]
Expand All @@ -69,7 +85,7 @@ Scriv provides two built-in templates:
.. [[[cog
include_file("src/scriv/templates/new_fragment.md.j2")
.. ]]]
.. code::
.. code-block:: jinja
<!--
A new scriv changelog fragment.
Expand All @@ -86,15 +102,15 @@ Scriv provides two built-in templates:
-->
{% endfor -%}
.. [[[end]]] (checksum: 98c2fb99a14f6a1fe327cde5eb00e9a5)
.. [[[end]]] (checksum: 522af8fd44433254fa64c58f89733d4d)
- ``new_fragment.rst.j2``: The default Jinja template for new reStructuredText
fragments:

.. [[[cog
include_file("src/scriv/templates/new_fragment.rst.j2")
.. ]]]
.. code::
.. code-block:: jinja
.. A new scriv changelog fragment.
{% if config.categories -%}
Expand All @@ -112,7 +128,7 @@ Scriv provides two built-in templates:
- A bullet item for this fragment. EDIT ME!
{% endif -%}
.. [[[end]]] (checksum: f1e1949e1f93a7963671861f6fb20189)
.. [[[end]]] (checksum: bdc8c8a24aa1aed2a40d07d08e8a939c)
Literal Prefix
--------------
Expand All @@ -130,13 +146,14 @@ In this case, the file ``myproj/__init__.py`` will be read, and the
Currently Python, .cfg, TOML, YAML and Cabal files are supported for literals,
but other syntaxes can be supported in the future.

When using a TOML file, the value is specified using periods to separate the
sections and key names::
When reading a literal from a TOML file, the value is specified using periods
to separate the sections and key names::

[scriv]
version = literal: pyproject.toml: project.version

In a YAML file, use periods in the value name to access dictionary keys::
For data from a YAML file, use periods in the value name to access dictionary
keys::

[scriv]
version = literal: galaxy.yaml: myproduct.versionString
Expand Down

0 comments on commit 5dafcc5

Please sign in to comment.