Skip to content

docs(contributing): basic layout #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/199.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs(contributing): basic layout
7 changes: 7 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"**/ExampleData*",
"**/LaunchWorkbench*",
"**/ClientWrapper*",
"links.rst",
]

# additional logos for the latex coverpage
Expand Down Expand Up @@ -256,6 +257,7 @@ def get_file_size_in_mb(file_path):
jinja_globals = {
"SUPPORTED_PYTHON_VERSIONS": ["3.11", "3.12", "3.13"],
"SUPPORTED_PLATFORMS": ["windows", "ubuntu"],
"PYWORKBENCH_VERSION": version,
}

jinja_contexts = {
Expand All @@ -275,3 +277,8 @@ def get_file_size_in_mb(file_path):
"source_hash": get_sha256_from_file(ARTIFACTS_SDIST),
},
}

# Common content for every RST file such us links
rst_epilog = ""
links_filepath = pathlib.Path(__file__).parent.absolute() / "links.rst"
rst_epilog += links_filepath.read_text(encoding="utf-8")
45 changes: 45 additions & 0 deletions doc/source/contribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Contribute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorgepiloto So much of this content seems like what we talked about as part of the url_include and snippet approach. Will it eventually be implemented as we planned? Your examples also sound rather PySDK-specific, not Workbench specific or generic enough to be part of a template. Should we consider that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PipKat, having this as a template would be the best. By using Tox, like this project does, the commands are the same for every project. This allows the content to be "templatized".

##########

Thank you for your interest in contributing to PyWorkbench. Contributions for
making the project better can include fixing bugs, adding new features, and
improving the documentation.

.. important::

This project adheres to the `Contributor Covenant Code of Conduct`_. By
participating, you agree to uphold this code of conduct.

Start by selecting your role in the project:
Copy link
Member

@PipKat PipKat Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Start by selecting your role in the project:
Overall guidance on contributing to a PyAnsys repository appears in
`Contribute <https://dev.docs.pyansys.com/how-to/contributing.html>`_
in the *PyAnsys developer's guide*. Ensure that you are thoroughly familiar
with this guide before attempting to contribute to PyWorkbench.
The following contribution information is specific to PyWorkbench. Start by
selecting your role in the project:

Adding content to make this Contribute topic and the one for PyHeart consistent.


.. grid:: 1 1 3 3

.. grid-item-card:: :fa:`user` User
:link: contribute/user
:link-type: doc
:padding: 2 2 2 2

Report bugs, suggest features, and ask questions.

.. grid-item-card:: :fa:`book` Documentarian
:link: contribute/documentarian
:link-type: doc
:padding: 2 2 2 2

Improve the documentation and write new content.

.. grid-item-card:: :fa:`laptop-code` Developer
:link: contribute/developer
:link-type: doc
:padding: 2 2 2 2

Fix bugs, add new features, and improve the codebase.

.. toctree::
:hidden:
:maxdepth: 3
:caption: Contribute

User<contribute/user>
Documentarian<contribute/documentarian>
Developer<contribute/developer>
184 changes: 184 additions & 0 deletions doc/source/contribute/developer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
Contribute as a developer
#########################

.. grid:: 1 1 3 3

.. grid-item-card:: :fa:`code-fork` Fork the repository
:padding: 2 2 2 2
:link: fork-the-repository
:link-type: ref

Fork the project to create a copy.

.. grid-item-card:: :fa:`download` Clone the repository
:padding: 2 2 2 2
:link: clone-the-repository
:link-type: ref

Clone the repository to download the copy to your local machine.

.. grid-item-card:: :fa:`download` Install for developers
:padding: 2 2 2 2
:link: install-for-developers
:link-type: ref

Install the project in editable mode.

.. grid-item-card:: :fa:`vial-circle-check` Run the tests
:padding: 2 2 2 2
:link: run-tests
:link-type: ref

Verify your changes to the project by running tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorgepiloto I see PyHeart has two additional sections: Code style compliance and Run the CI/CD pipelines. Do you possibly want to add this type of content to this library?


.. _fork-the-repository:

Fork the repository
===================

Forking the repository is the first step to contributing to the project. This
allows you to have your own copy of the project so that you can make changes without
affecting the main project. Once you have made your changes, you can submit a
pull request to the main project to have your changes reviewed and merged.

.. button-link:: https://github.com/ansys/pyworkbench/fork
:color: primary
:align: center
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:align: center
:align: left

We should be avoiding center alignment.


:fa:`code-fork` Fork this project

.. note::

If you are an Ansys employee, you can skip this step.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the instructions for external contributors?

Copy link
Member

@PipKat PipKat Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorgepiloto I can see now that my comment doesn't really make sense. The "Fork the repository" step doesn't have to be completed by Ansys employees, and external contributors can refer to GitHub resources or the PyAnsys dev guide for forking instructions. Should we say something to this effect though--or is it just obvious to developers? If so, just resolve this comment!


.. _clone-the-repository:

Clone the repository
====================

Make sure that you `configure SSH`_ with your GitHub
account. This allows you to clone the repository without having to use tokens
or passwords. Also, make sure you have `git`_ installed on your machine.

Clone the repository using SSH:

.. code-block:: bash

git clone [email protected]:ansys/pyworkbench

.. note::

If you are not an Ansys employee, you must fork the repository and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you are not an Ansys employee, you must fork the repository and
If you are not an Ansys employee, you must :ref:`fork the repository <fork-the-repository> and

replace ``ansys`` with your GitHub username in the ``git clone`` command.

.. _install-for-developers:

Install for developers
======================

Installing PyWorkbench in development mode lets you change the code
and see these changes reflected in your environment without having to reinstall
the library every time you make a change.

Virtual environment
-------------------

Start by navigating to the project's root directory:

.. code-block::

cd pyworkbench

Then, create a new virtual environment named ``.venv`` to isolate your system's
Python environment:

.. code-block:: text

python -m venv .venv

Finally, activate this environment:

.. tab-set::

.. tab-item:: Windows

.. tab-set::

.. tab-item:: CMD

.. code-block:: text

.venv\Scripts\activate.bat

.. tab-item:: PowerShell

.. code-block:: text

.venv\Scripts\Activate.ps1

.. tab-item:: macOS/Linux/UNIX

.. code-block:: text

source .venv/bin/activate

Development mode
----------------

Now, install PyWorkbench in editable mode:

.. code-block:: text

python -m pip install --editable .

Verify the installation by checking the version of the library:


.. code-block:: python

from ansys.workbench.core import __version__


print(f"pyworkbench version is {__version__}")

.. jinja::

.. code-block:: text

>>> pyworkbench version is {{ PYWORKBENCH_VERSION }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> pyworkbench version is {{ PYWORKBENCH_VERSION }}
>>> PyWorkbench version is {{ PYWORKBENCH_VERSION }}.


Install Tox
-----------

Once the project is installed, you can install `Tox`_. This is a cross-platform
automation tool. The main advantage of Tox is that it allows you to test your
project in different environments and configurations in a temporary and
isolated Python virtual environment.
Comment on lines +155 to +157
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
automation tool. The main advantage of Tox is that it allows you to test your
project in different environments and configurations in a temporary and
isolated Python virtual environment.
automation tool. The main advantage of Tox is that it eases routine tasks like project
testing, documentation generation, and wheel building in separate and isolated Python
virtual environments.

I replaced with the wording that was in PyHeart as it sounded better!


Install Tox:

.. code-block:: text

python -m pip install tox

Verify the Tox installation by listing all the different environments
(automation rules) for PyWorkbench:

.. code-block:: text

tox list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be python -m tox list like in the PyHeart doc?


.. _run-tests:

Run the tests
=============

Once you have made your changes, you can run the tests to verify that your
changes did not break the project. PyWorkbench tests support different markers
to avoid running the whole suite of tests. These markers are associated with a
dedicated Tox environment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we can use this instead--to match PyAnsys Heart wording:

PyWorkbench tests support different markers
to allow testing with or without coverage (and against specific Python versions).
These markers are associated with dedicated Tox environments.


.. code-block:: text

tox -e tests
139 changes: 139 additions & 0 deletions doc/source/contribute/documentarian.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
Contributing as a documentarian
###############################
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Contributing as a documentarian
###############################
Contribute as a documentarian
#############################


.. grid:: 1 1 3 3

.. grid-item-card:: :fa:`pencil` Write documentation
:padding: 2 2 2 2
:link: write-documentation
:link-type: ref

Learn how to get started, use, and contribute to the project.

.. grid-item-card:: :fa:`laptop-code` Add a new example
:padding: 2 2 2 2
:link: write-examples
:link-type: ref

Write a new example to showcase the capabilities of PyWorkbench.

.. grid-item-card:: :fa:`file-code` Build the documentation
:padding: 2 2 2 2
:link: build-documentation
:link-type: ref

Render the documentation to see your changes reflected.
Copy link
Member

@PipKat PipKat Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Render the documentation to see your changes reflected.
Build the documentation to see your changes rendered.


.. _write-documentation:

Write documentation
===================

`Sphinx`_ is the tool used to generate PyWorkbench documentation. You write most of the content
in `ReStructuredText`_ files. However, some of the content, like the
:ref:`examples <Examples>`, use a mix of `Markdown`_ and Python. If
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:ref:`examples <Examples>`, use a mix of `Markdown`_ and Python. If
:ref:`examples <Examples>`, use a mix of `Markdown`_ and Python files. If

you are interested in writing examples, see :ref:`writing examples <write-examples>`.
Copy link
Member

@PipKat PipKat Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
you are interested in writing examples, see :ref:`writing examples <write-examples>`.
you are interested in writing examples, see :ref:`write-examples`.

We just want to use the section title here.


The documentation is located in the ``doc/source`` directory. The landing page
is declared in the ``doc/source/index.rst`` file. The subdirectories contain
the pages of different documentation sections. Finally, the
``doc/source/_static/`` folder contains various assets like images, and CSS
Copy link
Member

@PipKat PipKat Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``doc/source/_static/`` folder contains various assets like images, and CSS
``doc/source/_static/`` directory contains various assets like images and CSS

files.

The layout of the ``doc/source`` directory is reflected in the URLs of the
online documentation pages. For example, the
``doc/source/contribute/documentarian.rst``file renders as
Copy link
Member

@PipKat PipKat Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``doc/source/contribute/documentarian.rst``file renders as
``doc/source/contribute/documentarian.rst`` file renders as the

``https://workbench.docs.pyansys.com/contribute/documentarian`` URL.

Thus, if you create a file, it important to follow these rules:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Thus, if you create a file, it important to follow these rules:
Thus, if you create a file, it is important to follow these rules:


- Use lowercase letters for file and directory names.
- Use short and descriptive names.
- Use hyphens to separate words.
- Play smart with the hierarchy of the files and directories.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Play smart with the hierarchy of the files and directories.
- Logically organize the hierarchy of the files and directories.


You must include all files in a table of contents. No orphan files are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You must include all files in a table of contents. No orphan files are
You must include all files in the table of contents. Sphinx does not permit any orphan files.

permitted. If a file is not included in the table of contents, Sphinx raises a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
permitted. If a file is not included in the table of contents, Sphinx raises a
If you do not include a file in the table of contents, Sphinx raises a

warning that causes the build to fail.

A table of contents can be declared using a directive like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A table of contents can be declared using a directive like this:
You declare the table of contents using a directive like this:


.. code-block:: rst

.. toctree::
:hidden:
:maxdepth: 3

path-to-file-A
path-to-file-B
path-to-file-C
...

The path to the file is relative to the directory where the table of contents
is declared.

.. _write-examples:

Write a new example
===================

The :ref:`examples <Examples>` section of the documentation showcases different
capabilities of PyWorkbench. Each example is a standalone Python script. Despite
being PY files, they are written in a mix of `Markdown`_ and Python. This
is possible thanks to the `myst-parser`_ Sphinx extension. In addition, these
Python files can be opened as Jupyter Notebooks thanks to the `jupytext`_
extension.

Documentarians writing new examples are encouraged to open a new Jupyter Lab
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt a documentarian (and am speaking for even myself) will know how to open a new Jupyter Lab session and write the example as a Jupyter Notebook. I feel like only a developer will know how to do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I will include the proper command in Tox and document it in here.

session and write the example as a Jupyter Notebook. This way, the
documentarian can test the code and see the output in real time. The created
Jupyter Notebook gets stored as a Python file automatically.

Note that the examples are contained in its own repository, which you can find
in `PyWorkbench examples repository`_.

Finally, here are some tips for writing examples:

- Start the example with an explanation of the main topic. For example, if you
are discussing a certain orbital maneuver, explain what that maneuver
entails. Similarly, if an example is centered around satellite coverage,
provide an explanation of what coverage is. Try to use as many relevant
keywords as possible in this section to optimize for Search Engine
Optimization.
Comment on lines +101 to +102
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
keywords as possible in this section to optimize for Search Engine
Optimization.
keywords as possible in this section for search engine
optimization.


- The second section of the example must be a problem statement. This statement
must include all of the parameters needed in the example, as well as a
description of what the example aims to determine. Write this section in an
imperative form.

- Include an explanation with each code cell. In a Jupyter Notebook, this
entails adding a Markdown cell before each code cell. The explanations should
be included before, not after, the corresponding code.

.. _build-documentation:

Build the documentation
=======================

`Tox`_ is used for automating the build of the documentation. There are
different environments for cleaning the build, building the documentation
in different formats such as HTML, and running the tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
in different formats such as HTML, and running the tests.
in different formats such as HTML and PDF, and running the tests.


The following environments are available:

.. dropdown:: Documentation environments
:animate: fade-in
:icon: three-bars

.. list-table::
:header-rows: 1
:widths: auto

* - Environment
- Command
* - doc-style
- python -m tox -e doc-style
* - doc-links
- python -m tox -e doc-links
* - doc-html
- python -m tox -e html
Loading