Skip to content
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

Add links to type tags #94

Merged
merged 7 commits into from
Feb 18, 2024
Merged

Add links to type tags #94

merged 7 commits into from
Feb 18, 2024

Conversation

haszi
Copy link
Contributor

@haszi haszi commented Feb 11, 2024

Add links to all <type>s in <methodsynopsis> and <constructorsynopsis> tags. Based on #33.

Includes the following>

  • refactored parameters to keep tracking of types the same way return types did
  • extracted functionality to handle simple nullable types and type <span> tags into its own method and used it for parameters too
  • added all types to the type link generating method
  • added link to the existing void rendering method
  • added tests for <methodsynopsis> and <constructorsynopsis> parameters, and <methodsynopsis> return types
  • updated an existing test that included types

haszi added 2 commits February 11, 2024 22:20
Add proper support for void element and add a test case to the approriate files.
@haszi
Copy link
Contributor Author

haszi commented Feb 12, 2024

Note: there are no tests for intersection types (neither on their own nor combined with union types) as I don't know how to write the appropriate xml and couldn't find any examples of it in the English docs.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Looks good just some questions/remarks

phpdotnet/phd/Package/PHP/XHTML.php Outdated Show resolved Hide resolved
Comment on lines 636 to 637
case "boolean":
case "integer":
Copy link
Member

Choose a reason for hiding this comment

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

Those, plus the "double" case should warn IMHO, as those are an alternative spelling for the proper built-in types that should not exist in the documentation any more. But can be a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about this and other warnings. There's a whole range of formatting and logic errors we could catch in Phd from whitespace in all sorts of tags, incompatible type combinations, etc.
If this was implemented as some sort of option that Phd could be called from the command line with, this whole doc checker could be added as an additional step to the documentations' pull request workflow. Maybe?

Copy link
Member

Choose a reason for hiding this comment

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

I think this makes sense, but I was certain we already had support for warnings in PhD as I had seen them 🤔

Maybe if it's a new render that runs fast and doesn't need indexing, having it run on CI would make sense. Last time it came up there were concerns about the CI taking too long, or running too frequently as a PR might be update often in quick successions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yeah. The error handler is right there in functions.php, a file included in everything Phd which I also never looked inside. :-)

So this format would be called with the --noindex option, it would have to override the createLink(), update() and appendData() methods at a minimum, and it's validation method(s) could return null and would raise warnings on validation errors. Sounds fairly simple, so it's probably far from it. :-)

Copy link
Member

Choose a reason for hiding this comment

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

As everything with PhD :D it looks simple and it isn't :D

phpdotnet/phd/Package/PHP/XHTML.php Outdated Show resolved Hide resolved
Replace type separator conditional with match.
Undo trimming type text.
Update tests.
Add methodparam to default chunk property and use it to initialize empty current chunk.
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Final late remark :)

@haszi
Copy link
Contributor Author

haszi commented Feb 15, 2024

I changed all type_separator properties to arrays and added a type_separator_stack property. The former holds the separator following the type with the corresponding index number in the types array, and the latter keeps track of the stack of separators during processing of tags/text and is used to fill the former.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Looks good to me :)

Sorry for the delay was at PHP UK

@Girgias Girgias merged commit 45cffd6 into php:master Feb 18, 2024
4 checks passed
@haszi
Copy link
Contributor Author

haszi commented Feb 18, 2024

Looks good to me :)

Sorry for the delay was at PHP UK

I appreciate you taking the time to review these PR at all. :-) Especially that you made it very clear that Phd is not too close to your heart, to put it mildly. :-)

@haszi haszi deleted the Add-links-to-types branch February 18, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants