Skip to content

Commit

Permalink
clean up variable names in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mcflugen committed Apr 1, 2024
1 parent 73fc90c commit a2232ab
Show file tree
Hide file tree
Showing 27 changed files with 105 additions and 123 deletions.
2 changes: 1 addition & 1 deletion babelizer/_post_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def remove_trailing_whitespace(path: str | Path) -> None:
def run(context: dict[str, Any]) -> None:
PROJECT_DIRECTORY = Path.cwd().resolve()

package_name = context["package_name"]
package_name = context["package"]["name"]
language = context["language"]

LIB_DIRECTORY = PROJECT_DIRECTORY / Path(package_name, "lib")
Expand Down
4 changes: 2 additions & 2 deletions babelizer/data/templates/.github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

- name: Test
run: |
python -c 'import {{ package_name }}'
python -c 'import {{ package.name }}'
{%- for babelized_class in components %}
bmi-test {{ package_name }}.bmi:{{ babelized_class }} -vvv
bmi-test {{ package.name }}.bmi:{{ babelized_class }} -vvv
{%- endfor %}
2 changes: 1 addition & 1 deletion babelizer/data/templates/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Credits
=======

* {{ info.full_name }} <{{ info.email }}>
* {{ info.package_author }} <{{ info.package_author_email }}>
8 changes: 4 additions & 4 deletions babelizer/data/templates/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
recursive-include {{ package_name }}/data *
recursive-include {{ package.name }}/data *
include LICENSE
include requirements.txt
include *.rst
include *.txt
include Makefile
include babel.toml
recursive-include {{ package_name }} *.pyx
recursive-include {{ package.name }} *.pyx
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs Makefile
recursive-exclude meta *
recursive-exclude recipe *
recursive-exclude {{ package_name }} *.cpp
recursive-exclude {{ package_name }} *.c
recursive-exclude {{ package.name }} *.cpp
recursive-exclude {{ package.name }} *.c
50 changes: 22 additions & 28 deletions babelizer/data/templates/README.rst
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
{{ '=' * package_name | length }}
{{ package_name }}
{{ '=' * package_name | length }}
{{ '=' * package.name | length }}
{{ package.name }}
{{ '=' * package.name | length }}

{% set is_open_source = open_source_license != 'Not open source' -%}

{% if is_open_source %}
.. image:: https://img.shields.io/badge/CSDMS-Basic%20Model%20Interface-green.svg
:target: https://bmi.readthedocs.io/
:alt: Basic Model Interface

.. image:: https://img.shields.io/badge/recipe-{{ package_name }}-green.svg
:target: https://anaconda.org/conda-forge/{{ package_name }}
.. image:: https://img.shields.io/badge/recipe-{{ package.name }}-green.svg
:target: https://anaconda.org/conda-forge/{{ package.name }}

.. image:: https://readthedocs.org/projects/{{ package_name | replace("_", "-") }}/badge/?version=latest
:target: https://{{ package_name | replace("_", "-") }}.readthedocs.io/en/latest/?badge=latest
.. image:: https://readthedocs.org/projects/{{ package.name | replace("_", "-") }}/badge/?version=latest
:target: https://{{ package.name | replace("_", "-") }}.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://github.com/{{ info.github_username }}/{{ package_name }}/actions/workflows/test.yml/badge.svg
:target: https://github.com/{{ info.github_username }}/{{ package_name }}/actions/workflows/test.yml
.. image:: https://github.com/{{ info.github_username }}/{{ package.name }}/actions/workflows/test.yml/badge.svg
:target: https://github.com/{{ info.github_username }}/{{ package.name }}/actions/workflows/test.yml

.. image:: https://github.com/{{ info.github_username }}/{{ package_name }}/actions/workflows/flake8.yml/badge.svg
:target: https://github.com/{{ info.github_username }}/{{ package_name }}/actions/workflows/flake8.yml
.. image:: https://github.com/{{ info.github_username }}/{{ package.name }}/actions/workflows/flake8.yml/badge.svg
:target: https://github.com/{{ info.github_username }}/{{ package.name }}/actions/workflows/flake8.yml

.. image:: https://github.com/{{ info.github_username }}/{{ package_name }}/actions/workflows/black.yml/badge.svg
:target: https://github.com/{{ info.github_username }}/{{ package_name }}/actions/workflows/black.yml
{%- endif %}
.. image:: https://github.com/{{ info.github_username }}/{{ package.name }}/actions/workflows/black.yml/badge.svg
:target: https://github.com/{{ info.github_username }}/{{ package.name }}/actions/workflows/black.yml


.. start-intro
Expand All @@ -44,7 +40,7 @@ Python and the Python Modeling Toolkit, PyMT.
- PyMT
{% for babelized_class, component in components|dictsort -%}
* - {{ component.library }}
- :class:`~{{ package_name }}.{{ babelized_class }}`
- :class:`~{{ package.name }}.{{ babelized_class }}`
-
.. code-block:: pycon
Expand All @@ -54,33 +50,31 @@ Python and the Python Modeling Toolkit, PyMT.
.. end-intro
{% if is_open_source %}
* Free software: {{ open_source_license }}
* Documentation: https://{{ package_name | replace("_", "-") }}.readthedocs.io.
{% endif %}
* Free software: {{ info.package_license }}
* Documentation: https://{{ package.name | replace("_", "-") }}.readthedocs.io.


Quickstart
==========

.. start-quickstart
To get started you will need to install the *{{ package_name }}* package.
To get started you will need to install the *{{ package.name }}* package.
Here are two ways to do so.

Install from conda-forge
------------------------

If the *{{ package_name }}* package is distributed on *conda-forge*, install it into your current environment with *conda*.
If the *{{ package.name }}* package is distributed on *conda-forge*, install it into your current environment with *conda*.

.. code:: bash
conda install -c conda-forge {{ package_name }}
conda install -c conda-forge {{ package.name }}
Install from source
-------------------

You can build and install the *{{ package_name }}* package from source using *conda* and *pip*.
You can build and install the *{{ package.name }}* package from source using *conda* and *pip*.

First, from the source directory, install package dependencies into your current environment with *conda*.

Expand Down Expand Up @@ -116,15 +110,15 @@ Model Interface (BMI), or as a PyMT plugin.

A BMI is provided by each component in this package:
{%- for babelized_class, component in components|dictsort -%}
:class:`~{{ package_name}}.{{ babelized_class }}`
:class:`~{{ package.name}}.{{ babelized_class }}`
{% endfor %}.


{% for babelized_class, component in components|dictsort -%}

.. code-block:: pycon
>>> from {{ package_name}} import {{ babelized_class }}
>>> from {{ package.name}} import {{ babelized_class }}
>>> model = {{ babelized_class }}()
>>> model.get_component_name() # Get the name of the component
>>> model.get_output_var_names() # Get a list of the component's output variables
Expand Down
2 changes: 1 addition & 1 deletion babelizer/data/templates/docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = {{ package_name }}
SPHINXPROJ = {{ package.name }}
SOURCEDIR = .
BUILDDIR = _build

Expand Down
2 changes: 1 addition & 1 deletion babelizer/data/templates/docs/api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# auto-generated with sphinx-apidoc
{{ package_name }}*.rst
{{ package.name }}*.rst
20 changes: 10 additions & 10 deletions babelizer/data/templates/docs/conf.py.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{ package_name }} documentation build configuration file, created by
# {{ package.name }} documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# This file is execfile()d with the current directory set to its
Expand All @@ -18,7 +18,7 @@
import os
import pathlib

import {{ package_name }}
import {{ package.name }}

docs_dir = os.path.dirname(__file__)

Expand Down Expand Up @@ -58,18 +58,18 @@ source_suffix = ".rst"
master_doc = "index"

# General information about the project.
project = "{{ package_name }}"
copyright = "{{ now|datetimeformat('%Y') }}, {{ info.full_name }}"
author = "{{ info.full_name }}"
project = "{{ package.name }}"
copyright = "{{ now|datetimeformat('%Y') }}, {{ info.package_author }}"
author = "{{ info.package_author }}"

# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = {{ package_name }}.__version__
version = {{ package.name }}.__version__
# The full version, including alpha/beta/rc tags.
release = {{ package_name }}.__version__
release = {{ package.name }}.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -96,7 +96,7 @@ todo_include_todos = False
# a list of builtin themes.
#
html_theme = "furo"
html_title = "{{ package_name }}"
html_title = "{{ package.name }}"


# Theme options are theme-specific and customize the look and feel of a
Expand All @@ -105,7 +105,7 @@ html_title = "{{ package_name }}"
#
html_theme_options = {
"announcement": None,
"source_repository": "https://github.com/{{ info.github_username }}/{{ package_name }}/",
"source_repository": "https://github.com/{{ info.github_username }}/{{ package.name }}/",
"source_branch": "main",
"source_directory": "docs",
"sidebar_hide_name": False,
Expand All @@ -132,7 +132,7 @@ html_static_path = ["_static"]
# -- Options for HTMLHelp output ---------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "{{ package_name }}doc"
htmlhelp_basename = "{{ package.name }}doc"

# -- Options for intersphinx extension ---------------------------------------

Expand Down
22 changes: 11 additions & 11 deletions babelizer/data/templates/docs/developer_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ Developer Install

.. important::

The following commands will install *{{ package_name }}* into your current environment. Although
not necessary, we **highly recommend** you install *{{ package_name }}* into its own
The following commands will install *{{ package.name }}* into your current environment. Although
not necessary, we **highly recommend** you install *{{ package.name }}* into its own
:ref:`virtual environment <virtual_environments>`.

If you will be modifying code or contributing new code to *{{ package_name }}*, you will first
need to get *{{ package_name }}*'s source code and then install *{{ package_name }}* from that code.
If you will be modifying code or contributing new code to *{{ package.name }}*, you will first
need to get *{{ package.name }}*'s source code and then install *{{ package.name }}* from that code.

Source Install
--------------

*{{ package_name }}* is actively being developed on GitHub, where the code is freely available.
*{{ package.name }}* is actively being developed on GitHub, where the code is freely available.
If you would like to modify or contribute code, you can either clone our
repository

.. code-block:: bash
git clone git://github.com/pymt-lab/{{ package_name }}.git
git clone git://github.com/pymt-lab/{{ package.name }}.git
or download the `tarball <https://github.com/{{ info.github_username }}/{{ package_name }}/tarball/master>`_
or download the `tarball <https://github.com/{{ info.github_username }}/{{ package.name }}/tarball/master>`_
(a zip file is available for Windows users):

.. code-block:: bash
curl -OL https://github.com/{{ info.github_username }}/{{ package_name }}/tarball/master
curl -OL https://github.com/{{ info.github_username }}/{{ package.name }}/tarball/master
Once you have a copy of the source code, you can install it into your current
Python environment,
Expand All @@ -38,21 +38,21 @@ Python environment,

.. code-block:: bash
cd {{ package_name }}
cd {{ package.name }}
mamba install --file=requirements.txt
pip install -e .
.. tab:: conda

.. code-block:: bash
cd {{ package_name }}
cd {{ package.name }}
conda install --file=requirements.txt
pip install -e .
.. tab:: pip

.. code-block:: bash
cd {{ package_name }}
cd {{ package.name }}
pip install -e .
8 changes: 4 additions & 4 deletions babelizer/data/templates/docs/environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ should stick with *pip*.
.. code-block:: bash
conda install mamba -c conda-forge
mamba create -n {{ package_name }}
mamba activate {{ package_name }}
mamba create -n {{ package.name }}
mamba activate {{ package.name }}
.. tab:: conda

.. code-block:: bash
conda create -n {{ package_name }}
conda activate {{ package_name }}
conda create -n {{ package.name }}
conda activate {{ package.name }}
.. tab:: venv

Expand Down
10 changes: 5 additions & 5 deletions babelizer/data/templates/docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.. image:: _static/logo-light.svg
:align: center
:scale: 15%
:alt: {{ package_name }}
:target: https://{{ package_name }}.readthedocs.org/
:alt: {{ package.name }}
:target: https://{{ package.name }}.readthedocs.org/
:class: only-light

.. image:: _static/logo-dark.svg
:align: center
:scale: 15%
:alt: {{ package_name }}
:target: https://{{ package_name }}.readthedocs.org/
:alt: {{ package.name }}
:target: https://{{ package.name }}.readthedocs.org/
:class: only-dark

.. include:: ../README.rst
Expand All @@ -23,7 +23,7 @@

quickstart
usage
API <api/{{ package_name }}>
API <api/{{ package.name }}>
babel
.. contributing
Expand Down
10 changes: 5 additions & 5 deletions babelizer/data/templates/docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ Quickstart

.. note::

The following commands will install *{{ package_name}}* into your current
The following commands will install *{{ package.name}}* into your current
environment. Although not necessary, we **highly recommend** you install
*{{ package_name}}* into its own
*{{ package.name}}* into its own
:ref:`virtual environment <virtual_environments>`.

.. include:: ../README.rst
:start-after: .. start-quickstart
:end-before: .. end-quickstart

If you would like the very latest development version of *{{ package_name}}*
or want to modify or contribute code to the *{{ package_name}}* project,
If you would like the very latest development version of *{{ package.name}}*
or want to modify or contribute code to the *{{ package.name}}* project,
you will need to do a :ref:`developer installation <developer_install>` of
*{{ package_name }}* from source.
*{{ package.name }}* from source.
Loading

0 comments on commit a2232ab

Please sign in to comment.