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

feat(settings): Add support to tables in toml settings #362

Closed
wants to merge 1 commit into from

Conversation

danieljmv01
Copy link
Contributor

@danieljmv01 danieljmv01 commented Oct 28, 2021

Correct loop so that it iterates over the values and not the keys of the custom fragment types if provided.

Resolves #361

  • Iterate through values if types is a mapping instead of an array.

Resolves: twisted/#361

@danieljmv01 danieljmv01 marked this pull request as ready for review October 28, 2021 15:58
Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks.

Can you add a test for custom types?

In this way we will make sure that this feature will always work and it will not be broken by future work.

But if you don't have time for a test, that is ok.

We can merge it as it is.

Thanks again!

@danieljmv01
Copy link
Contributor Author

Yes, I think I can do it tomorrow. Thanks!

@danieljmv01 danieljmv01 force-pushed the bug-361 branch 2 times, most recently from 4bc9135 to 692e364 Compare November 3, 2021 18:15
@@ -30,6 +30,61 @@ def test_base(self):
self.assertEqual(config["filename"], "NEWS.rst")
self.assertEqual(config["underlines"], ["=", "-", "~"])

def test_custom_types(self):
Copy link
Member

Choose a reason for hiding this comment

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

can we these as 2 tests with separate docstring.

I am not sure that is the targeted difference between readme_format and alternative_format.

For the docstring, my suggetion is something like this

Custom fragment categories can be defined inside the toml config file using implicit file extension.
The file extension is the same as directory name.
Custom fragment categories can be defined inside the toml config file using custom file extension.
The file extension is define by the section name.

Does these docstrings make sense?
Is this what it is tested?

You can refactor the shared code in a helper function...but I think that it helps to have 2 separate test functions with 2 docstrings as they are covering 2 separate uses cases.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@adiroiban
Copy link
Member

and since this is a new feature, can you also update the configuration ? Thanks!

@codecov
Copy link

codecov bot commented Nov 3, 2021

Codecov Report

Merging #362 (692e364) into master (0e6a479) will increase coverage by 0.05%.
The diff coverage is 100.00%.

❗ Current head 692e364 differs from pull request most recent head fbc813a. Consider uploading reports for the commit fbc813a to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #362      +/-   ##
==========================================
+ Coverage   96.81%   96.86%   +0.05%     
==========================================
  Files          20       20              
  Lines        1194     1214      +20     
  Branches      108      110       +2     
==========================================
+ Hits         1156     1176      +20     
  Misses         20       20              
  Partials       18       18              
Impacted Files Coverage Δ
src/towncrier/_settings.py 96.59% <100.00%> (+0.24%) ⬆️
src/towncrier/test/test_settings.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e6a479...fbc813a. Read the comment docs.

* Iterate through values if types is a mapping instead of an array.

Resolves: twisted/twisted#361
Signed-off-by: danieljmv01 <danieljmv01@gmail.com>
@danieljmv01
Copy link
Contributor Author

danieljmv01 commented Nov 3, 2021

and since this is a new feature,

Initially I didn't know that I was passing the configuration in an unexpected way, and I considered this a bug. I tried to just fix it, without adding new features.
But, since this is not a bug, but a new feature, I would like to stop using (or make it optional) the "directory" key if passing tables (it will be mandatory if using a table array).
Also, I would like to make optional including "showcontent" key (e.g., assume that type has "showcontent": True if not passed).
Do you consider that doing this is ok or do you prefer those changes in an additional PR?

can you also update the configuration ? Thanks!

I am not sure about what do you refer. The configuration docs?

Thanks!

@danieljmv01 danieljmv01 changed the title fix(settings): Fix custom types parsing feat(settings): Add support to tables in toml settings Nov 3, 2021
@adiroiban
Copy link
Member

Is this PR still valid or can be closed as invalid?

My understanding is that you found a way to use the existing towncrier functionality to implement your requirements.

I guess that we ended up with this PR since the existing documentation was not clear enough.

So maybe the documentation can be improved.

@danieljmv01
Copy link
Contributor Author

Hi @adiroiban I would like to update the PR, I want to update the docs regarding this topic, but the docs sources appears to exists in a branch that is not master.
Is this intended and should I create another PR to that branch or should I take the docs/ dir as it is in the other branch and include it with the changes in this PR?

@adiroiban
Copy link
Member

@danieljmv01 . I have created #367 to solve the docs issue.

I prefer to have the code and docs in the same repo.

I agree that things are very confusing with the current setup.

So, if you have time, I am more than happy to review and approve a PR which moves the doc files into the main branch.

@danieljmv01
Copy link
Contributor Author

Perfect, I will do it today after work.

@adiroiban
Copy link
Member

@danieljmv01 can we close this PR? is there any value in having it merged?

Thanks

@danieljmv01
Copy link
Contributor Author

@adiroiban as is right now: no I don't see any value added.

I wanted to keep changes as minimal as possible, and ended not adding value. What I would like is to give users a simpler, clearer and more intuitive and clear way to configure custom fragment types. I want to support this:

code-block-1:

    [tool.towncrier.type.feat]
    name = "Features"
    showcontent = true

Since the title of each table would describe the custom fragment type (see code-block-1) the field directory is not necessary in this way of configuration.

In the alternative (existing) way to configure custom types you have to include the directory field, that then will be use as key when transforming the array of dicts to a dict.

I would rather wait until #368 is merged to rebase and update this, so I can document this in this PR. After rebasing this branch, I will update the code to support omitting the directory field. If you still consider that it adds no value, then I'm fine with closing this PR.

@adiroiban
Copy link
Member

Ok.No hurry from my side.
let me know when this PR is ready from a new review.

@danieljmv01
Copy link
Contributor Author

@adiroiban I pushed to another branch since this is not a bug.

I have created #370, I will close this one.

@danieljmv01 danieljmv01 deleted the bug-361 branch February 15, 2022 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"TypeError: string indices must be integers" when trying to use custom newsfragments types.
2 participants