Skip to content

Commit

Permalink
Double backticks rather than single ones for code in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardo-rodrigues committed Jan 9, 2024
1 parent 024fe4a commit a26d887
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ little bit helps, and credit will always be given.
Bug reports
===========

When `reporting a bug <https://github.com/scikit-hep/decaylanguage/issues>`_ please include:
When ``reporting a bug <https://github.com/scikit-hep/decaylanguage/issues>``_ please include:
* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
Expand Down Expand Up @@ -37,7 +37,7 @@ Development
To set up ``decaylanguage`` for local development:

1. Fork `decaylanguage <https://github.com/scikit-hep/decaylanguage>`_
1. Fork ``decaylanguage <https://github.com/scikit-hep/decaylanguage>``_
(look for the "Fork" button).
2. Clone your fork locally::
Expand All @@ -50,7 +50,7 @@ To set up ``decaylanguage`` for local development:
Now you can make your changes locally.
4. When you're done making changes, run all the checks, doc builder and spell checker with `nox <https://nox.thea.codes/en/stable/>`_ one command::
4. When you're done making changes, run all the checks, doc builder and spell checker with ``nox <https://nox.thea.codes/en/stable/>``_ one command::
nox
Expand Down
16 changes: 8 additions & 8 deletions src/decaylanguage/dec/dec.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def parse(self, include_ccdecays: bool = True) -> None:
Parse the given .dec decay file(s) according to the default Lark parser
and specified options.
Use the method `load_additional_decay_models` before `parse` to load decay models
Use the method ``load_additional_decay_models`` before ``parse`` to load decay models
that might not yet be available in DecayLanguage.
Parameters
Expand Down Expand Up @@ -274,7 +274,7 @@ def load_grammar(
**options: Any,
) -> None:
"""
DEPRECATED, please use "`load_additional_decay_models`" instead.
DEPRECATED, please use "``load_additional_decay_models``" instead.
Load a Lark grammar definition file, either the default one,
or a user-specified one, optionally setting Lark parsing options.
Expand All @@ -296,7 +296,7 @@ def load_grammar(

warnings.warn(
"This method is deprecated, please add unknown decay models by passing them to "
"`load_additional_decay_models` instead before parsing the decayfile.",
"``load_additional_decay_models`` instead before parsing the decayfile.",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -309,7 +309,7 @@ def load_grammar(
def load_additional_decay_models(self, *models: str) -> None:
"""
Add one or more EvtGen decay models in addition to the ones already provided via
`decaylanguage.dec.enums.known_decay_models`.
``decaylanguage.dec.enums.known_decay_models``.
Parameters
----------
Expand Down Expand Up @@ -373,7 +373,7 @@ def _generate_edit_terminals_callback(self) -> Callable[[TerminalDef], None]:
def edit_model_name_terminals(t: TerminalDef) -> None:
"""
Edits the terminals of the grammar to replace the model name placeholder with the actual names of the models,
see `Model_NAME_PLACEHOLDER` in the default grammar file `decaylanguage/data/decfile.lark`.
see ``Model_NAME_PLACEHOLDER`` in the default grammar file ``decaylanguage/data/decfile.lark``.
The decay models are sorted by length and escaped to match the default Lark behavior.
"""

Expand Down Expand Up @@ -1151,7 +1151,7 @@ def _replacement(self, t: Token) -> Token:
if t.value not in self.define_defs:
raise ValueError(
f"Decay model or ModelAlias {t.value} is not defined. Please load the decay model with "
"`load_additional_decay_models` or define a ModelAlias in the decayfile."
"``load_additional_decay_models`` or define a ModelAlias in the decayfile."
)
return self.define_defs[t.value]

Expand Down Expand Up @@ -1289,8 +1289,8 @@ def find_charge_conjugate_match(
Find the charge-conjugate particle name making use of user information
from "ChargeConj" statements in a decay file.
The name `ChargeConj(pname)` is returned if all matching "routes" fail,
see `charge_conjugate_name(...)` function.
The name ``ChargeConj(pname)`` is returned if all matching "routes" fail,
see ``charge_conjugate_name(...)`` function.
"""
# Check the list of particle-antiparticle matches provided ;-)
if dict_cc_names:
Expand Down
34 changes: 17 additions & 17 deletions src/decaylanguage/decay/decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DaughtersDict(CounterStr):
Note
----
This class assumes EvtGen particle names, though this assumption is only relevant
for the `charge_conjugate` method.
for the ``charge_conjugate`` method.
Otherwise, all other class methods smoothly deal with
any kind of particle names (basically an iterable of strings).
Expand All @@ -64,7 +64,7 @@ def __init__(
Note
----
This class assumes EvtGen particle names, though this assumption is only relevant
for the `charge_conjugate` method (refer to its documentation).
for the ``charge_conjugate`` method (refer to its documentation).
Otherwise, all other class methods smoothly deal with
any kind of particle names (basically an iterable of strings).
Expand Down Expand Up @@ -188,7 +188,7 @@ class DecayMode:
Note
----
This class assumes EvtGen particle names, though this assumption is only
relevant for the `charge_conjugate` method.
relevant for the ``charge_conjugate`` method.
Otherwise, all other class methods smoothly deal
with any kind of particle names (basically an iterable of strings).
"""
Expand Down Expand Up @@ -224,7 +224,7 @@ def __init__(
Note
----
This class assumes EvtGen particle names, though this assumption is only
relevant for the `charge_conjugate` method.
relevant for the ``charge_conjugate`` method.
Otherwise, all other class methods smoothly deal
with any kind of particle names (basically an iterable of strings).
Expand Down Expand Up @@ -277,7 +277,7 @@ def from_dict(
Note
----
This class assumes EvtGen particle names, though this assumption is only
relevant for the `charge_conjugate` method.
relevant for the ``charge_conjugate`` method.
Otherwise, all other class methods smoothly deal
with any kind of particle names (basically an iterable of strings).
Expand Down Expand Up @@ -386,7 +386,7 @@ def describe(self) -> str:
def to_dict(self) -> dict[str, int | float | str | list[str]]:
"""
Return the decay mode as a dictionary in the format understood
by the `DecayChainViewer` class.
by the ``DecayChainViewer`` class.
Examples
--------
Expand Down Expand Up @@ -470,17 +470,17 @@ def _build_decay_modes(
decay_modes: dict[str, DecayMode], dc_dict: DecayChainDict
) -> None:
"""
Internal recursive function that identifies and creates all `DecayMode` instances
effectively contained in the dict representation of a `DecayChain`,
which is for example the format returned by `DecFileParser.build_decay_chains(...)`,
Internal recursive function that identifies and creates all ``DecayMode`` instances
effectively contained in the dict representation of a ``DecayChain``,
which is for example the format returned by ``DecFileParser.build_decay_chains(...)``,
Given the input dict representation of a `DecayChain`
it returns a dict of mother particles and their final states as `DecayMode` instances.
Given the input dict representation of a ``DecayChain``
it returns a dict of mother particles and their final states as ``DecayMode`` instances.
Parameters
----------
decay_modes: dict
A dict to be populated with the decay modes `DecayMode`
A dict to be populated with the decay modes ``DecayMode``
built from the input decay chain dictionary.
dc_dict: dict
The input decay chain dictionary.
Expand Down Expand Up @@ -740,7 +740,7 @@ class DecayChain:
can only define a single decay mode.
2) This class does not assume any kind of particle names (EvtGen, PDG).
It is nevertheless advised to default use EvtGen names for consistency
with the defaults used in the related classes `DecayMode` and `DaughtersDict`,
with the defaults used in the related classes ``DecayMode`` and ``DaughtersDict``,
unless there is a good motivation not to.
"""

Expand Down Expand Up @@ -777,7 +777,7 @@ def from_dict(cls, decay_chain_dict: DecayChainDict) -> Self:
"""
Constructor from a decay chain represented as a dictionary.
The format is the same as that returned by
`DecFileParser.build_decay_chains(...)`.
``DecFileParser.build_decay_chains(...)``.
"""
try:
assert len(decay_chain_dict.keys()) == 1
Expand All @@ -792,7 +792,7 @@ def from_dict(cls, decay_chain_dict: DecayChainDict) -> Self:

def top_level_decay(self) -> DecayMode:
"""
Return the top-level decay as a `DecayMode` instance.
Return the top-level decay as a ``DecayMode`` instance.
"""
return self.decays[self.mother]

Expand Down Expand Up @@ -928,7 +928,7 @@ def _print(
def to_dict(self) -> DecayChainDict:
"""
Return the decay chain as a dictionary representation.
The format is the same as `DecFileParser.build_decay_chains(...)`.
The format is the same as ``DecFileParser.build_decay_chains(...)``.
Examples
--------
Expand Down Expand Up @@ -980,7 +980,7 @@ def flatten(
Note
----
After flattening the only `DecayMode` metadata kept is that of the top-level decay,
After flattening the only ``DecayMode`` metadata kept is that of the top-level decay,
i.e. that of the mother particle (nothing else would make sense).
Examples
Expand Down
20 changes: 10 additions & 10 deletions src/decaylanguage/decay/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
Submodule with classes and utilities to visualize decay chains.
Decay chains are typically provided by the parser of .dec decay files,
see the `DecFileParser` class.
see the ``DecFileParser`` class.
"""

from __future__ import annotations
Expand Down Expand Up @@ -42,7 +42,7 @@ class DecayChainViewer:
>>> dcv # doctest: +SKIP
When not in notebooks the graph can easily be visualized with the
`graphviz.Digraph.render` or `graphviz.Digraph.view` functions, e.g.:
``graphviz.Digraph.render`` or ``graphviz.Digraph.view`` functions, e.g.:
>>> dcv.graph.render(filename="test", format="pdf", view=True, cleanup=True) # doctest: +SKIP
"""

Expand All @@ -59,10 +59,10 @@ def __init__(
Parameters
----------
decaychain: dict
Input decay chain in dict format, typically created from `decaylanguage.DecFileParser.build_decay_chains`
after parsing a .dec decay file, or from building a decay chain representation with `decaylanguage.DecayChain.to_dict`.
Input decay chain in dict format, typically created from ``decaylanguage.DecFileParser.build_decay_chains``
after parsing a .dec decay file, or from building a decay chain representation with ``decaylanguage.DecayChain.to_dict``.
attrs: optional
User input `graphviz.Digraph` class attributes.
User input ``graphviz.Digraph`` class attributes.
See also
--------
Expand Down Expand Up @@ -91,7 +91,7 @@ def safe_html_name(name: str) -> str:
Note
----
The match is done using a conversion map rather than via
`Particle.from_evtgen_name(name).html_name` for 2 reasons:
``Particle.from_evtgen_name(name).html_name`` for 2 reasons:
- Some decay-file-specific "particle" names (e.g. cs_0)
are not in the PDG table.
- No need to load all particle information if all that's needed
Expand Down Expand Up @@ -183,23 +183,23 @@ def has_subdecay(ds: list[Any]) -> bool:
@property
def graph(self) -> graphviz.Digraph:
"""
Get the actual `graphviz.Digraph` object.
Get the actual ``graphviz.Digraph`` object.
The user now has full control ...
"""
return self._graph

def to_string(self) -> str:
"""
Return a string representation of the built graph in the DOT language.
The function is a trivial shortcut for ``graphviz.Digraph.source`.
The function is a trivial shortcut for ``graphviz.Digraph.source``.
"""
return self.graph.source # type: ignore[no-any-return]

def _instantiate_graph(
self, **attrs: dict[str, bool | int | float | str]
) -> graphviz.Digraph:
"""
Return a ``graphviz.Digraph` class instance using the default attributes
Return a ``graphviz.Digraph`` class instance using the default attributes
specified in this class:
- Default graph attributes are overridden by input by the user.
- Class and node and edge defaults.
Expand All @@ -226,7 +226,7 @@ def _instantiate_graph(

def _get_default_arguments(self) -> dict[str, bool | int | float | str]:
"""
`graphviz.Digraph` default arguments.
``graphviz.Digraph`` default arguments.
"""
return {
"name": "DecayChainGraph",
Expand Down
4 changes: 2 additions & 2 deletions src/decaylanguage/utils/particleutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def charge_conjugate_name(name: str, pdg_name: bool = False) -> str:
-------
out: str
Either the EvtGen or PDG charge-conjugate particle name
depending on the value of parameter `pdg_name`.
depending on the value of parameter ``pdg_name``.
"""
if pdg_name:
try:
Expand Down Expand Up @@ -121,7 +121,7 @@ def particle_list_from_string_name(name: str) -> list[Particle]:

def _from_group_dict_list(mat: dict[str, Any]) -> list[Particle]:
"""
Internal helper class for the functions `from_string` and `from_string_list`
Internal helper class for the functions ``from_string`` and ``from_string_list``
for fuzzy finding of particle names used by AmpGen.
"""
kw: dict[str, Any] = {
Expand Down
4 changes: 2 additions & 2 deletions src/decaylanguage/utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def filter_lines(
class DescriptorFormat:
"""
Class to help with setting the decay descriptor format. The format is stored as a
class-level variable: `DescriptorFormat.config`.
class-level variable: ``DescriptorFormat.config``.
Examples
--------
Expand Down Expand Up @@ -140,7 +140,7 @@ def set_config(decay_pattern: str, sub_decay_pattern: str) -> None:
def format_descriptor(mother: str, daughters: str, top: bool = True) -> str:
"""
Apply the format to one "layer" of the decay. Does not handle nested
decays itself. It is assumed that the `daughters` string already contains
decays itself. It is assumed that the ``daughters`` string already contains
any sub-decays.
Parameters
Expand Down

0 comments on commit a26d887

Please sign in to comment.