From bd04fb77daa8181213c821edeab15ee3f9b4f042 Mon Sep 17 00:00:00 2001 From: Kerry McAdams <58492561+klmcadams@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:58:08 -0400 Subject: [PATCH] feat: add member_order to autoapi (#495) Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> --- doc/changelog.d/495.added.md | 1 + doc/source/user-guide/autoapi.rst | 4 ++++ src/ansys_sphinx_theme/extension/autoapi.py | 1 + 3 files changed, 6 insertions(+) create mode 100644 doc/changelog.d/495.added.md diff --git a/doc/changelog.d/495.added.md b/doc/changelog.d/495.added.md new file mode 100644 index 00000000..be6b2978 --- /dev/null +++ b/doc/changelog.d/495.added.md @@ -0,0 +1 @@ +feat: add member_order to autoapi \ No newline at end of file diff --git a/doc/source/user-guide/autoapi.rst b/doc/source/user-guide/autoapi.rst index e137e3e5..6fbdcaea 100644 --- a/doc/source/user-guide/autoapi.rst +++ b/doc/source/user-guide/autoapi.rst @@ -29,6 +29,9 @@ and set the ``ansys_sphinx_theme_autoapi`` theme options in the ``html_theme_opt By default, this is set to ``False``. - ``package_depth``: The depth of the package. By default, this is set to ``3``. This is the ``namespace`` depth of the package. For example, if the package is ``ansys``, the depth is ``1``. If the package is ``ansys.foo``, the depth is ``2``. +- ``member_order``: The order to document members. By default, this is set to ``bysource``. Other options include + ``alphabetical``, which orders members by their name (case sensitive), or ``groupwise``, which orders members by their type + and alphabetically. All these options can be set in the ``conf.py`` file of your Sphinx project. @@ -54,6 +57,7 @@ All these options can be set in the ``conf.py`` file of your Sphinx project. "ignore": [], "add_toctree_entry": False, "package_depth": 3, + "member_order": "bysource", } } diff --git a/src/ansys_sphinx_theme/extension/autoapi.py b/src/ansys_sphinx_theme/extension/autoapi.py index 1fdb887f..eb86df99 100644 --- a/src/ansys_sphinx_theme/extension/autoapi.py +++ b/src/ansys_sphinx_theme/extension/autoapi.py @@ -76,6 +76,7 @@ def prepare_jinja_env(jinja_env) -> None: app.config["autoapi_options"] = autoapi.get("options", AUTOAPI_OPTIONS) app.config["autoapi_ignore"] = autoapi.get("ignore", []) app.config["autoapi_add_toctree_entry"] = autoapi.get("add_toctree_entry", True) + app.config["autoapi_member_order"] = autoapi.get("member_order", "bysource") # HACK: The ``autoapi_dirs`` should be given as a relative path to the conf.py. relative_autoapi_dir = os.path.relpath(