[PATCH] D120712: [clang-format][docs] handle explicit enum values
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 1 09:59:37 PST 2022
MyDeveloperDay added inline comments.
================
Comment at: clang/docs/tools/dump_format_style.py:174-175
return '* ``%s`` (in configuration: ``%s``)\n%s' % (
- self.name,
- re.sub('.*_', '', self.config),
+ self.clean_name,
+ self.clean_config,
doxygen2rst(indent(self.comment, 2)))
----------------
kwk wrote:
> MyDeveloperDay wrote:
> > Feels like there is repetition here
> Are you suggesting to introduce a function `name_only` that looks like this?
>
> ```lang=python
> def name_only(s: str) -> str:
> return s.split("=", 1)[0].strip()
> ```
>
> If so, should this be a member function of `EnumValue` or where would you see it?
>
> I'm not fond of introducing this function TBH because the name suggest it to be very generically usable when in fact it does just a simple thing. If you pass `foo and bar` to it you get `foo and bar` but that's not a usable name of any kind, right?
yes I was suggesting adding a function, feel free to suggest a better name.
However all this said, I don't understand the need, you say your going to introduce explicit values to the enum, but why? I'm not a massive fan of that either, normally it means someone wants to abuse the enum by using the values and that IMHO can means people start doing things like taking values away from each other and/or doing a range loop from one value to another, and this becomes very unstable when enum values are added in between.
But please enlighten us as to what use the values will have I'm keen to learn.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120712/new/
https://reviews.llvm.org/D120712
More information about the cfe-commits
mailing list