-
Notifications
You must be signed in to change notification settings - Fork 752
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
8.3: Document Random\IntervalBoundary #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 |
<simpara> | ||
The <enumname>Random\IntervalBoundary</enumname> cases determines if the | ||
boundary values can be returned or not by | ||
<methodname>Random\Randomizer::getFloat</methodname>. | ||
</simpara> |
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.
I'm not sure if I would make it specific to Randomizer::getFloat()
. It's the only current use case and it will likely remain the only use case, but technically the enum would be reusable for other things. The detail that it will determine whether the boundaries can be returned is already explained in the $boundary
parameter of getFloat()
.
Perhaps something like:
The Random\IntervalBoundary enum specifies whether or not an interval includes the boundary values within the set of values lying in the interval.
<enumitemdescription> | ||
The <parameter>min</parameter> value may be returned. | ||
However, the <parameter>max</parameter> value will never be returned. | ||
</enumitemdescription> |
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.
A left-open interval. The lower boundary is included in the interval, the upper boundary is not.
<enumitem> | ||
<enumidentifier>ClosedClosed</enumidentifier> | ||
<enumitemdescription> | ||
Both the <parameter>min</parameter> and <parameter>max</parameter> value may be returned. |
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.
A closed interval. Both boundary values are included in the interval.
<enumitem> | ||
<enumidentifier>OpenClosed</enumidentifier> | ||
<enumitemdescription> | ||
The <parameter>max</parameter> value may be returned. |
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.
A right-open interval. The upper boundary is included in the interval, the lower boundary is not.
<enumitem> | ||
<enumidentifier>OpenOpen</enumidentifier> | ||
<enumitemdescription> | ||
Neither the <parameter>min</parameter> or <parameter>max</parameter> will ever be returned. |
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.
An open interval. Neither boundary value is included in the interval.
Ah and: Should the PR be renamed? It's not just a proposal at this point, no? |
Co-authored-by: Tim Düsterhus <[email protected]>
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?