diff --git a/doc/source/documentation_style/coding_style.rst b/doc/source/coding_style/beyond_pep8.rst
similarity index 94%
rename from doc/source/documentation_style/coding_style.rst
rename to doc/source/coding_style/beyond_pep8.rst
index a6093711f..b334d0d92 100644
--- a/doc/source/documentation_style/coding_style.rst
+++ b/doc/source/coding_style/beyond_pep8.rst
@@ -1,10 +1,6 @@
-Coding Style and Best Practices
-###############################
-This page provides best practices applicable to the `PyAnsys
-`_ project. The intent is
-not to repeat coding style documentation but rather to state
-the approach used by the PyAnsys project when there are any
-delineations, clarifications, or additional procedures above and
+Beyond PEP8
+###########
+This topic describes any delineations, clarifications, or additional procedures above and
beyond `PEP8 `__.
For example, `Stack Overflow Answer `_
@@ -87,7 +83,7 @@ Python, an alternative is to create a custom ``DeprecationError``.
"""Empty init."""
RuntimeError.__init__(self, message)
-You then use this custom ``DeprecationError`` in place of an ``Exception``.
+You can then use this custom ``DeprecationError`` in place of an ``Exception``.
.. code:: python
@@ -142,7 +138,7 @@ also be used to perform regression testing to verify that the code is
executing as expected.
This is an important feature of maintainable documentation as examples
-must always match the API they are documenting. When using `doctest``
+must always match the API they are documenting. When using ``doctest``
through ``pytest``, any changes within the API without corresponding
changes in the documentation will trigger doctest failures.
@@ -270,8 +266,8 @@ example by referencing the key ``icepak``.
"""
-Useful Features
-~~~~~~~~~~~~~~~
+Useful ``doctest`` Features
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ellipses for Random Output
**************************
@@ -299,7 +295,7 @@ To support this, ``doctest`` must be run with the option set to allow ellipses.
The directive ``# doctest: +SKIP`` can be added to any line of a
docstring example so that it is not executed in ``doctest-modules``.
This is useful for examples that cannot run within ``pytest`` or have
-side-effects that will affect the other tests if they are run during
+side effects that will affect the other tests if they are run during
the ``doctest`` session.
.. code :: python
diff --git a/doc/source/coding_style/flake8.rst b/doc/source/coding_style/flake8.rst
index 1b64abaf2..1780f642a 100644
--- a/doc/source/coding_style/flake8.rst
+++ b/doc/source/coding_style/flake8.rst
@@ -2,7 +2,7 @@
Style Guide Enforcement
=======================
-The following sections describe the use of `Flake8`_ for `PEP8`_ style
+This topic describes the use of `Flake8`_ for `PEP8`_ style
enforcement and the minimum standards expected. PyAnsys libraries
are expected to be consistent with these guidelines.
@@ -27,7 +27,7 @@ Configuring Flake8
Flake8 supports configuring a specific set of style rules to
enforce. This configuration can be stored in your library in a
``setup.cfg``, ``tox.ini``, or ``.flake8`` file. PyAnsys libraries
-store the flake8 configuration in a ``.flake8`` file at the root of the
+store the Flake8 configuration in a ``.flake8`` file at the root of the
repository.
Here is an example of a ``.flake8`` configuration file from a PyAnsys
@@ -44,48 +44,50 @@ library:
statistics = True
Flake8 has many options that can be set within the configuration file.
-A list of possible options can be found `here `__.
+For a list and descriptions, see this `Flake8 documentation topic
+`__.
-The above configuration defines the following options:
+The example configuration defines the following options:
- ``exclude``
- This denotes subdirectories and ``doc/_build``, along with all
+ Denotes subdirectories and ``doc/_build``, along with all
``__init__.py`` files to be excluded from the check.
- ``select``
- This is a sequence of error codes that flake8 will report errors
+ Sequence of error codes that Flake8 will report errors
for. The set in the above configuration is a basic set of errors to
check for and is not an exhaustive list.
- A full list of error codes and their descriptions can be found `here `__.
+ For a full list of error codes and their descriptions, see this `Flake8
+ documentation topic `__.
- ``count``
- The total number of errors is printed at the end of the check.
+ Total number of errors to print at the end of the check.
- ``max-complexity``
- This sets the maximum allowed McCabe complexity value for a block of code.
+ Sets the maximum allowed McCabe complexity value for a block of code.
The value of 10 was chosen because it is a common default.
- ``max-line-length``
- This denotes the maximum line length for any one line of code.
+ Denotes the maximum line length for any one line of code.
The `PEP8`_ standard advises a maximum line length of 79. Because
this is a bit limiting in some cases, the maximum line length
recommended for a PyAnsys library is 100.
- ``statistics``
- This enables the number of occurrences of each error or warning code
+ Number of occurrences of each error or warning code
to be printed as a report at the end of the check.
Running Flake8
--------------
-First, to install flake8, run:
+First, to install Flake8, run:
.. code::
python -m pip install flake8
-Then, flake8 can be run from inside your project directory by executing:
+Then, you can run Flake8 from inside your project directory by executing:
.. code::
@@ -95,7 +97,7 @@ This uses the configuration defined in the ``.flake8`` file to
run the style checks on the appropriate files within the project and
report any errors.
-In PyAnsys libraries, flake8 is run as part of the CI/CD for code style.
+In PyAnsys libraries, Flake8 is run as part of the CI/CD for code style.
This action is run as a required check on pull requests, preventing
code in violation of style rules from being merged into the code
base.
@@ -110,12 +112,12 @@ the formatting tool `black`_.
On completing a code change, and before committing, `black`_ can be
run to reformat the code, following the PEP8 guidelines enforced through
-flake8. This will limit any manual code changes needed to address style
+Flake8. This will limit any manual code changes needed to address style
rules.
.. _black: https://black.readthedocs.io/en/stable/
-Optionally, it is possible to automate the use of ``black``. This can be
+Optionally, it is possible to automate the use of `black`_. This can be
done with the tool `pre-commit`_. Setting up a `pre-commit hook
to run black `_
will automatically format the code before committing. This simple way of
@@ -128,7 +130,7 @@ PEP8 guidelines requires minimal manual effort.
Minimum Standards
~~~~~~~~~~~~~~~~~
The following section describes the minimum set of code style standards
-expected in an PyAnsys library.
+expected in a PyAnsys library.
* `W191`_ - **Indentation contains tabs.**
@@ -193,11 +195,11 @@ expected in an PyAnsys library.
* `E501`_ - **Line too long.**
All code lines should not exceed 100 characters. The
- `PEP8 line length `_
- guidelines suggest a maximum line length of 79. Following this limit
+ `PEP8 line length guideline `_
+ suggests a maximum line length of 79. Following this limit
is not as necessary today due to modern screen sizes. The suggested maximum
length of 100 can be easier to accommodate and can still support
- viewing files side-by-side in code editors.
+ viewing files side by side in code editors.
* `F401`_ - **Module imported but unused.**
diff --git a/doc/source/coding_style/index.rst b/doc/source/coding_style/index.rst
index f9a3e7896..5a59528fe 100644
--- a/doc/source/coding_style/index.rst
+++ b/doc/source/coding_style/index.rst
@@ -4,7 +4,7 @@ Coding Style
************
PyAnsys libraries are expected to follow `PEP8`_ and
-be consistent in style and formatting with the "big three"
+be consistent in style and formatting with the 'big three'
data science libraries: `NumPy`_, `SciPy`_, and `pandas`_.
.. _NumPy: https://numpy.org/
@@ -24,5 +24,6 @@ data science libraries: `NumPy`_, `SciPy`_, and `pandas`_.
:hidden:
:maxdepth: 3
+ pep8_best_practices
+ beyond_pep8
flake8
- best_practices
diff --git a/doc/source/coding_style/best_practices.rst b/doc/source/coding_style/pep8_best_practices.rst
similarity index 91%
rename from doc/source/coding_style/best_practices.rst
rename to doc/source/coding_style/pep8_best_practices.rst
index 1b3da7e2b..046ab000b 100644
--- a/doc/source/coding_style/best_practices.rst
+++ b/doc/source/coding_style/pep8_best_practices.rst
@@ -1,10 +1,10 @@
.. _best_practices:
-Best Practices
-==============
-The following sections summarize the key points from `PEP8`_ and how
+PEP 8 Best Practices
+====================
+This topic summarizes key points from `PEP8`_ and how
they apply to PyAnsys libraries. The goal is for PyAnsys libraries to
-be consistent in style and formatting with the "big three"
+be consistent in style and formatting with the `big three`
data science libraries: `NumPy`_, `SciPy`_, and `pandas`_.
.. _NumPy: https://numpy.org/
@@ -22,7 +22,7 @@ might only be discovered during runtime.
.. _ImportError: https://docs.python.org/3/library/exceptions.html#ImportError
-Avoid:
+Instead of:
.. code:: python
@@ -40,13 +40,13 @@ Use:
return math.log(8, x)
-For better readability, you should group imports following this order:
+For better readability, group imports in this order:
#. Standard library imports
#. Related third-party imports
-#. Local application/library-specific imports
+#. Local application- or library-specific imports
-Avoid:
+Instead of:
.. code:: python
@@ -75,7 +75,7 @@ Use:
You should place imports in separate lines unless they are
modules from the same package.
-Avoid:
+Instead of:
.. code:: python
@@ -99,9 +99,10 @@ Use:
You should avoid using wild cards in imports because doing so
-can make it difficult to detect undefined names. For more details see `Python Anti-Patterns: using wildcard imports <(https://docs.quantifiedcode.com/python-anti-patterns/maintainability/from_module_import_all_used.html>`_.
+can make it difficult to detect undefined names. For more information,
+see `Python Anti-Patterns: using wildcard imports <(https://docs.quantifiedcode.com/python-anti-patterns/maintainability/from_module_import_all_used.html>`_.
-Avoid:
+Instead of:
.. code:: python
@@ -157,7 +158,7 @@ Inside a class, use a single line before any method definition.
"""Second method docstring"""
return
-To make it clear when a "paragraph" of code is complete and a new section
+To make it clear when a 'paragraph' of code is complete and a new section
is starting, use a blank line to separate logical sections.
Instead of:
@@ -227,9 +228,8 @@ classic loop.
Naming Conventions
------------------
-It is important to use concise and descriptive names for classes,
-methods, functions, and constants for readable and maintainable
-code. Regardless of the programming language, you must follow these
+To achieve readable and maintainable code, use concise and descriptive names for classes,
+methods, functions, and constants. Regardless of the programming language, you must follow these
global rules to determine the correct names:
#. Choose descriptive and unambiguous names.
@@ -264,7 +264,7 @@ from PyPi.
Class Naming Conventions
~~~~~~~~~~~~~~~~~~~~~~~~
-Use `CamelCase `_ when naming classes. Do not separate words
+Use `camel case `_ when naming classes. Do not separate words
with underscores.
.. code:: python
@@ -301,7 +301,7 @@ words with underscores to improve readability.
"""This method should only be called from ``MyClass``.
Protected methods can be called from inherited classes,
- unlike private methods, which names are "mangled" to avoid
+ unlike private methods, which names are 'mangled' to avoid
these methods from being called from inherited classes.
"""
@@ -337,7 +337,7 @@ readability.
Comments
---------
+~~~~~~~~
Because a PyAnsys library generally involves multiple physics domains,
users reading its source code do not have the same background as
the developers who wrote it. This is why it is important for a library
@@ -403,7 +403,7 @@ avoided:
Focus on writing self-documenting code and using short but
descriptive variable names.
-Avoid:
+Instead of:
.. code:: python
@@ -416,21 +416,21 @@ Use:
user_name = 'John Smith'
-Documentation Convention
-------------------------
+Docstring Conventions
+~~~~~~~~~~~~~~~~~~~~~
A docstring is a string literal that occurs as the first statement in
a module, function, class, or method definition. A docstring becomes
the doc special attribute of the object.
Write docstrings for all public modules, functions, classes, and
-methods. Docstrings are not necessary for non-public methods, but such
+methods. Docstrings are not necessary for private methods, but such
methods should have comments that describe what they do.
To create a docstring, surround the comments with three double quotes
on either side.
For a one-line docstring, keep both the starting and ending ``"""`` on the
-same line.
+same line:
.. code:: python
@@ -440,27 +440,27 @@ For a multi-line docstring, put the ending ``"""`` on a line by itself.
PyAEDT follows the `numpydoc
`_
-documentation style, which is used by `numpy `_,
+docstring style, which is used by `numpy `_,
`scipy `_, `pandas
`_, and a variety of other Python open
-source projects. For a full description of the code style, reference
-`PyAnsys sphinxdocs `_.
+source projects. For more information on docstrings for PyAnsys
+libraries, see :ref:`api_documentation`.
Programming Recommendations
----------------------------
-This section provides some `PEP8
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The following sections provide some `PEP8
`_ suggestions for removing
ambiguity and preserving consistency. They address some common pitfalls
when writing Python code.
Booleans and Comparisons
-~~~~~~~~~~~~~~~~~~~~~~~~
+------------------------
Don't compare Boolean values to ``True`` or ``False`` using the
equivalence operator.
-Avoid:
+Instead of:
.. code:: python
@@ -478,7 +478,7 @@ Knowing that empty sequences are evaluated to ``False``, don't compare the
length of these objects but rather consider how they would evaluate
by using ``bool(