sphinx-contrib / sphinxcontrib-towncrier

An RST directive for injecting a Towncrier-generated changelog draft containing fragments for the unreleased (next) project version. Demo: https://ansible-pylibssh.rtfd.io/changelog. Docs: https://sphinxcontrib-towncrier.rtfd.io
https://pypi.org/p/sphinxcontrib-towncrier
BSD 3-Clause "New" or "Revised" License
19 stars 18 forks source link

Support finding `towncrier.toml` automatically #81

Closed HealthyPear closed 1 year ago

HealthyPear commented 1 year ago

The configuration of towncrier can also be placed in a dedicated configuration file named towncrier.toml with the same syntax, which is meant to be stored in the same place of pyproject.toml and takes precedence over it.

It seems to me that this package doesn't respect this, and looks only at pyproject.toml:

WARNING: Missing key 'towncrier' in file XXXX/docs/source/../../pyproject.toml

HealthyPear commented 1 year ago

https://github.com/sphinx-contrib/sphinxcontrib-towncrier/blob/098c78169e15465531bc03e10bc42d4827d265d9/src/sphinxcontrib/towncrier/ext.py#L109

webknjaz commented 1 year ago

This is a great idea, a PR is welcome! Note that you should be able to pass a full path to the towncrier config via conf.py IIRC. I don't remember the details, though.. Somebody would need to dig into the source code.

webknjaz commented 1 year ago

https://github.com/sphinx-contrib/sphinxcontrib-towncrier/blob/098c78169e15465531bc03e10bc42d4827d265d9/src/sphinxcontrib/towncrier/ext.py#L109

@HealthyPear if you look one line below, you'll see that's redefined with an incoming setting, so it should be possible to set up towncrier_draft_config_path = 'towncrier.toml' in conf.py ­— that should work.

Though, you're right, and it'd be nice to have this Sphinx extension find it automatically…

jaraco commented 1 year ago

This issue also affects Setuptools now that jaraco/skeleton is adopting towncrier.

webknjaz commented 1 year ago

Have you tried the workaround above? I'm on vacation this week so won't be able to look into it right now.

HealthyPear commented 1 year ago

@webknjaz sorry for the big delay on this: I can confirm that your suggested workaround works!

It is true that this should be caught automatically, but since it's a configurable option I think this is sufficient (though it should be added to the documentation).

webknjaz commented 1 year ago

I'd prefer the FR to be implemented, still. So I won't be closing this issue even of someone sends a docs PR, which is always welcome :)

jaraco commented 1 year ago

Have you tried the workaround above? I'm on vacation this week so won't be able to look into it right now.

Yes, the workaround is in place (pypa/setuptools@227ade7f8).

jaraco commented 1 year ago

Unfortunately, it looks like towncrier doesn't expose the config file discovery without also parsing the config, meaning this project will necessarily have to provide its own copy of the logic.