-
Notifications
You must be signed in to change notification settings - Fork 736
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
Proposal for Enum markup #3419
base: master
Are you sure you want to change the base?
Proposal for Enum markup #3419
Conversation
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.
Can't comment on the Docbook specifics, but here's some words for you to include to make the page useful right from the start.
This is very much in line with the new class markup you used which is great. PhD support should not be an issue and most of the work will be done when the new class markup is converted. I assume the rendered enum synopsis would look something like this: |
</enumitemdescription> | ||
</enumitem> | ||
|
||
</enumsynopsis> |
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.
Hmm, so far classsynopsis
elements only contained the signature itself, but not the descriptions. Is it intentional that it's different for enumsynopsis
elements?
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.
The DocBook 5.2 markup describes the markup in that manner: https://tdg.docbook.org/tdg/5.2/enumsynopsis (via the <enumitem>
tag) so yes.
For reference, the <classsynopsis>
description is located here: https://tdg.docbook.org/tdg/5.2/classsynopsis
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.
That's a pity, because this way automatic replacement is going to be much more difficult, since there are free form values in the generated enumsynopsis item, and we should somehow try to preserve them.
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.
That's a pity, because this way automatic replacement is going to be much more difficult, since there are free form values in the generated enumsynopsis item, and we should somehow try to preserve them.
I'm not sure whether that's difficult? One just needs to ignore the <enumitemdescription>
tag, but also, I don't see how an enum would change after it has been introduced.
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.
classsynopsis elements are generated based on the current stub definitions for each class/interface/enum signature which are encountered on class synopses pages (https://github.com/php/php-src/blob/0ad2e4d997549c85aac61120a94ea3da0b709339/build/gen_stub.php#L5560) and then the respective elements are replaced altogether one by one (the replaceAndCompareXmls()
call a few lines below).
This means that if there is anything inside classsynopsis elements which are not generatable based on the definitions in stubs, then those things will be removed. A workaround for enums could be that the enum case descriptions are retrieved from the manual pages and they are inserted into the generated elements... This complicates the process, but maybe it's not that difficult if this is going to be the preferred approach.
Also, It has just came to my mind that these descriptions would result in enum definitions which are completely not valid PHP code 🤔 while for the rest of the symbols, we generate at least a remotely valid PHP code since a few years.
<!-- TODO New Reftitle entity --> | ||
&reftitle.classsynopsis; | ||
|
||
<enumsynopsis> |
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.
Just a FYI: we should also think about the markup for implemented interfaces, enum constants, methods
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.
Right... I forgot that PHP enums can do this sort of stuff...
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.
Yeah, and I've just realized that e.g. fieldsynopsis
elements inside enumsynopsis
are not even allowed in DocBook. :/ (Or are they?)
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.
Yeah, they are not, because DocBook (rightfully) assumes that enums are just that, and not our weird thing based on objects.
I think we might need to use the <classsynopsis>
tags when an enum has constants, properties, or methods. However, I would imagine this to be rare for internal enums.
<enumname>IntervalBoundary</enumname> | ||
<!-- <modifier role="enum_backing_type">string|int</modifier> --> | ||
|
||
<enumitem> |
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.
Other types of symbols have a dedicated section title for classes and interfaces. Would it be a good idea to add them for enums as well?
I've just drafted a PR which adds support for this feature in stubs: php/php-src#14369 I intentionally modified Random\IntervalBoundary and also checked in the generated result for testing purposes. |
Since all enums implement either the UnitEnum or the BackedEnum interface and inherit their default method implementation, all enum markup will have to include both an <section xml:id="enum.intervalboundary.synopsis">
&reftitle.classsynopsis;
<enumsynopsis>
... // enum (cases) markup
</enumsynopsis>
<classsynopsis>
... // regular class markup
</classsynopsis>
</section>
What do you think? |
Hmm, interesting option... I wouldn't have thought about it. But I think I'd prefer to just have one element which has to be |
This will now also be required for |
Hmm, this is ugly. We can't use Okay, let's be pragmatic and use |
We will need the I still don't think any internal enum is going to actually implement interfaces or have any sort of properties, even if this is allowed in userland. So the "problem" seems rather theoretical, and even then it would be possible to add the above "hack fix" with the |
I'm a bit worried about translations. If we have a number of enum documented with On the other hand, maybe we will never need more, and I'm overthinking. |
What I meant, is that it would be perfectly fine for both markups to coexist, where the |
Part of: #2796
Fixes:
Requires:
I kinda wish I could use a
<refentry>
tag instead, but we need to insert this into a<book>
element which requires an intermediate tag anyway, so steal the suboptimal markup from classes.@haszi do you think this makes sense, and is this not too complicated to add support to PhD for it?