Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.

feat: add support for enums - #374

Merged
dandhlee merged 1 commit into
mainfrom
support_enums
May 2, 2024
Merged

dandhlee merged 1 commit into
mainfrom
support_enums

Conversation

@dandhlee

@dandhlee dandhlee commented May 2, 2024

Copy link
Copy Markdown
Contributor

Enums section was unformatted until now, adding a formatter for it.

I've considered stripping individual parts (name, value and description) to put into the table format, however we don't have any prior history of formatting enums this way. I've decided to just format the entire block in a codeblock, which is a significant improvement over what we have.

See b/195689267 for the staged example.

Mixed in a bit of lint/formatting fixes.

Fixes b/195689267.

@dandhlee
dandhlee requested a review from dansaadati May 2, 2024 03:06
@product-auto-label product-auto-label Bot added the size: s Pull request size is small. label May 2, 2024
@dandhlee
dandhlee marked this pull request as ready for review May 2, 2024 03:08
@dandhlee
dandhlee requested review from a team May 2, 2024 03:08
Comment thread docfx_yaml/extension.py
summary_parts = []
attributes = []
attribute_type_token = ":type:"
enum_type_token = "Values:"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I see there are other keywords defined as constants at the top of the file. Can this one also be a constant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If it was just values docstring tokenized I would have kept it up there but since we're looking for the specific Values: string I've kept it here.

Comment thread docfx_yaml/extension.py
if part.lstrip('\n').startswith('..'):
if (potential_keyword := part.lstrip('\n')) and (
potential_keyword.startswith('..') or
potential_keyword.startswith(enum_type_token)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can this just be included in the extract_keyword logic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, but unfortunately the entire section didn't get tokenized:

Values:
  name(val):
    ...

Other parts that do get tokenized and/or has proper format appear in this format:

.. note::
   ...

.. example::
   ...

@dandhlee dandhlee left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

Comment thread docfx_yaml/extension.py
summary_parts = []
attributes = []
attribute_type_token = ":type:"
enum_type_token = "Values:"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If it was just values docstring tokenized I would have kept it up there but since we're looking for the specific Values: string I've kept it here.

Comment thread docfx_yaml/extension.py
if part.lstrip('\n').startswith('..'):
if (potential_keyword := part.lstrip('\n')) and (
potential_keyword.startswith('..') or
potential_keyword.startswith(enum_type_token)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, but unfortunately the entire section didn't get tokenized:

Values:
  name(val):
    ...

Other parts that do get tokenized and/or has proper format appear in this format:

.. note::
   ...

.. example::
   ...

@dandhlee
dandhlee merged commit 4575ffe into main May 2, 2024
@dandhlee
dandhlee deleted the support_enums branch May 2, 2024 06:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants