-
Couldn't load subscription status.
- Fork 411
Allow custom_categories to define a regex or a name for each category child
#1418
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
Conversation
… child
A custom category can now specify a regex for each of its children
by using an object with a regex key instead of just a string
to find all of the declaration matching that regex.
For example:
```
custom_categories:
- name: some_category_name
children:
- some_exact_name
- regex: some_regex
```
Will create a category containing:
- the declaration "some_exact_name" (if it's found)
- all the declaration that match the "some_regex" regex. (e.g. "some_regex", "some_regex1", ...)
00d231a to
f783f9f
Compare
Handle the received string to match just as a string
CHANGELOG.md
Outdated
| ##### Enhancements | ||
|
|
||
| * None. | ||
| * Allow `custom_categories` to specify a regex for a child. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need two spaces at the end of the line (markdown linebreak)
lib/jazzy/grouper.rb
Outdated
| end | ||
| else | ||
| doc_index.lookup_regex(selector['regex']) | ||
| .sort_by { |doc| doc.name.downcase } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking behind the downcase here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not enough thinking I would say 😄. I'll remove it.
lib/jazzy/grouper.rb
Outdated
| selected = if selector.is_a?(String) | ||
| unless doc = doc_index.lookup(selector) | ||
| warn 'WARNING: No documented top-level declarations match ' \ | ||
| "name \"#{name}\" specified in categories file" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name is wrong here, cut + paste error - is causing the swift_spec test to fail
|
Thanks for the PR, looks basically good! I like the approach of using the yaml structure to do this. You should be able to run Please also add a change to the (I expect to have some solid open source time in a few weeks and will be doing an Xcode26-ish release then, should be able to pull in this too.) |
Add custom_categories documentation in readme
|
@johnfairh Thanks for the quick review, had missed the linter as I'm pretty new to this repo. Now all warnings should be fixed. And thanks again for looking into this and for the time you'll dedicate to the new release in a few weeks time. |
|
Thanks this is great. Don't worry about the Danger failure, just one refactoring left to tidy up. |
[] without return was a no op and [single_doc] was returned which was [nil] therefore causing a crash.
|
Looks like this will go cleanly on top of Xcode26... |
Hi, I was seeing that #688 was still open and that a PR was welcome for that, so I've tried to have a go at it.
Hopefully this can be merged as I think it could be a good addition and it would be very useful to me (and to others apparently).
Thank you guys for all your work on this!
A custom category can now specify a regex for each of its children by using an object with a regex key instead of just a string to find all of the declaration matching that regex.
For example:
Will create a category containing: