Skip to content
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

Update docs around version discovery #602

Merged
merged 5 commits into from
May 23, 2024
Merged
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
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Top level keys
``version``
The version of your project.

Python projects that provide the ``package`` key can have the version to be automatically determined from a ``__version__`` variable in the package's module.
Python projects that provide the ``package`` key, if left empty then the version will be automatically determined from the installed package's version metadata or a ``__version__`` variable in the package's module.

If not provided or able to be determined, the version must be passed explicitly by the command line argument ``--version``.

Expand Down
22 changes: 15 additions & 7 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,27 @@ Create this folder::
The ``.gitignore`` will remain and keep Git from not tracking the directory.


Detecting Dates & Versions
--------------------------
Detecting Version
-----------------

``towncrier`` needs to know what version your project is, and there are two ways you can give it:
``towncrier`` needs to know what version your project is when generating news files.
These are the ways you can provide it, in order of precedence (with the first taking precedence over the second, and so on):

- For Python 2/3-compatible projects, a ``__version__`` in the top level package.
This can be either a string literal, a tuple, or an `Incremental <https://github.com/twisted/incremental>`_ version.
- Manually passing ``--version=<myversionhere>`` when interacting with ``towncrier``.
1. Manually pass ``--version=<myversionhere>`` when interacting with ``towncrier``.
2. Set a value for the ``version`` option in your configuration file.
3. For Python projects with a ``package`` key in the configuration file:

As an example, if your package doesn't have a ``__version__``, you can manually specify it when calling ``towncrier`` on the command line with the ``--version`` flag::
- install the package to use its metadata version information
- add a ``__version__`` in the top level package that is either a string literal, a tuple, or an `Incremental <https://github.com/twisted/incremental>`_ version

As an example, you can manually specify the version when calling ``towncrier`` on the command line with the ``--version`` flag::

$ towncrier build --version=1.2.3post4


Setting Date
------------

``towncrier`` will also include the current date (in ``YYYY-MM-DD`` format) when generating news files.
You can change this with the ``--date`` flag::

Expand Down
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/432.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify version discovery behavior.
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/602.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify version discovery behavior.
Loading