-
Notifications
You must be signed in to change notification settings - Fork 55
Generate correct links for <type> elements #33
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
|
Could you please rebase? |
bb6997d to
6b08acb
Compare
|
Done the rebase and did some clean-up for the support for I also don't really understand the purpose of the |
phpdotnet/phd/Package/PHP/XHTML.php
Outdated
| $href = "language.types.$t"; | ||
| break; | ||
| case "mixed": | ||
| case "void": |
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.
There's a format_void() methodas well, which apparently renders void return types.
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.
Also, I added 2 <span class="type">?</span> tags yesterday, which IMO should be updated as well
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.
Hum, I don't really know how to do this frankly, because from my understanding this works on the XML? So I would imagine it gets initially rendered with links like A|null before getting transformed again?
And I'll drop void then, didn't know it was already handled
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, phd converts XML to HTML, but in case of simple nullable types, I had to discard the render of the null subtype, and insert a <span class="type">?</span> before the other subtype of the union type gets rendered. So what I wanted to ask you is to add the href directly to these HTML tags as well.
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 you point me to where to the name of this function?
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.
format_type() doesn't call format_type_text() so I didn't update it as I imagine this is already not displaying links.
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.
format_type() is only called for rendering the tag itself, but format_type_text() is automatically called for the text inside the type tags. Now, that you changed format_methodsynopsis(), ? has the link at the return type positions, but since format_type_text() was left out, ? at parameter positions`are missing the links.
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.
There's still another problem with simple nullable parameters:
/* Methods */
public __construct(
? $locale,
int $dateType,
int $timeType,
IntlTimeZone|DateTimeZone|string|null $timezone = null,
IntlCalendar|int|null $calendar = null,
string $pattern = ""
)
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.
Frankly I do not understand how the fuck these method call happen, so I have no clue if what I'm doing makes any sense. When I opened this PR initially it was just after a commit which broke the generation of the links, so I looked at this and tried to fix it. But I have ZERO understanding of PhD, and just trying to figure out how shit works here is... painful.
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.
It's a bit better now: ? characters both at the parameter as well as the return type position have the link. However, neither void, not false have them. As mentioned previously, you can add the link directly to the former one at phpdotnet/phd/Package/Generic/XHTML.php:1045, but I'm not sure what to do with false.
In order to fix the issue with the disappearing type in case of simple nullable types, you have to apply the following patch:
Index: phpdotnet/phd/Package/PHP/XHTML.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php
--- a/phpdotnet/phd/Package/PHP/XHTML.php (revision e64f1141d524e7ad56e0a88c5cf161cfe5a6341d)
+++ b/phpdotnet/phd/Package/PHP/XHTML.php (date 1627560074288)
@@ -546,12 +546,14 @@
case "array":
case "object":
case "resource":
+ case "callable":
+ case "iterable":
+ $href = "language.types.$t";
+ break;
case "null":
if ($this->simple_nullable) {
return "";
}
- case "callable":
- case "iterable":
$href = "language.types.$t";
break;
case "mixed":
| if ($this->cchunk["methodsynopsis"]["returntypes"]) { | ||
| $types = []; | ||
| foreach ($this->cchunk["methodsynopsis"]["returntypes"] as $return_type) { | ||
| $formatted_type = self::format_type_if_object_or_pseudo_text($return_type, "type"); |
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 believe phpdotnet\phd\Package_PHP_XHTML::format_type_if_object_or_pseudo_text is not used anywhere else so itcan be removed
6b08acb to
49b2b7d
Compare
| foreach ($this->cchunk["methodsynopsis"]["returntypes"] as $return_type) { | ||
| $formatted_type = self::format_type_if_object_or_pseudo_text($return_type, "type"); | ||
| $formatted_type = self::format_type_text($return_type, "type"); | ||
| if ($formatted_type === false) { |
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 false return is impossible now
phpdotnet/phd/Package/PHP/XHTML.php
Outdated
| $href = "language.types.$t"; | ||
| break; | ||
| case "mixed": | ||
| case "void": |
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.
It's a bit better now: ? characters both at the parameter as well as the return type position have the link. However, neither void, not false have them. As mentioned previously, you can add the link directly to the former one at phpdotnet/phd/Package/Generic/XHTML.php:1045, but I'm not sure what to do with false.
In order to fix the issue with the disappearing type in case of simple nullable types, you have to apply the following patch:
Index: phpdotnet/phd/Package/PHP/XHTML.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php
--- a/phpdotnet/phd/Package/PHP/XHTML.php (revision e64f1141d524e7ad56e0a88c5cf161cfe5a6341d)
+++ b/phpdotnet/phd/Package/PHP/XHTML.php (date 1627560074288)
@@ -546,12 +546,14 @@
case "array":
case "object":
case "resource":
+ case "callable":
+ case "iterable":
+ $href = "language.types.$t";
+ break;
case "null":
if ($this->simple_nullable) {
return "";
}
- case "callable":
- case "iterable":
$href = "language.types.$t";
break;
case "mixed":
|
Closed in favour of #94 |
No description provided.