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 support for rendering more logical classsynopsis markup #77

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 6, 2023

while allowing the old markup to render.

@mallardduck @heiglandreas

I'll push an example of some doc-en changes that would render this markup.

From my testing (which is not the most extensive) nothing is broken.

@mallardduck
Copy link
Contributor

mallardduck commented Jul 6, 2023

So far the only "issue" i'm seeing is that this doesn't remove the redundant name from methods. AFAIK the current behaviour there is the desired result, one where local methods do not have the prefix of the class/interface they are within.

I think correcting this would require duplicating some of what is done for classes currently. So when the method is processed by format_classsynopsis_methodsynopsis_methodname_text it needs a reference of the current class like $this->cchunk["classsynopsis"]["classname"]. Doing a quick dump debug it looks like this is the default value of false instead of the current Interface name. Might be worth introducing a new interfacename field unless you just want to reuse the classname.

Screenshot 2023-07-06 at 12 49 59 PM

@Girgias
Copy link
Member Author

Girgias commented Jul 7, 2023

So far the only "issue" i'm seeing is that this doesn't remove the redundant name from methods. AFAIK the current behaviour there is the desired result, one where local methods do not have the prefix of the class/interface they are within.

I think correcting this would require duplicating some of what is done for classes currently. So when the method is processed by format_classsynopsis_methodsynopsis_methodname_text it needs a reference of the current class like $this->cchunk["classsynopsis"]["classname"]. Doing a quick dump debug it looks like this is the default value of false instead of the current Interface name. Might be worth introducing a new interfacename field unless you just want to reuse the classname.
Screenshot 2023-07-06 at 12 49 59 PM

Yeah that was the issue, I reused the classname field as otherwise when you have an interface list it would potentially override stuff.

Also added support for <ooexception> while I was there and did some refactoring to group stuff together.

Comment on lines -10 to -16
'classname' => array(
/* DEFAULT */ 'span',
'ooclass' => array(
/* DEFAULT */ 'format_suppressed_tags',
'classsynopsisinfo' => 'format_classsynopsisinfo_ooclass_classname',
),
),
Copy link
Member Author

Choose a reason for hiding this comment

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

For reference, this is useless, as it duplicated the same information from the generic XHTML format.

@mallardduck
Copy link
Contributor

Think this is looking pretty good from testing on my end. Only "issue" is that (php/doc-en#2563) is missing my previous changes for DS interfaces. So it reverts some items back to abstract modifiers I had removed from affected DS interface methods. Maybe not a big deal tho since rebase should fix that and I'll need to make adjustments so those work with this PR.

@Girgias
Copy link
Member Author

Girgias commented Jul 10, 2023

Think this is looking pretty good from testing on my end. Only "issue" is that (php/doc-en#2563) is missing my previous changes for DS interfaces. So it reverts some items back to abstract modifiers I had removed from affected DS interface methods. Maybe not a big deal tho since rebase should fix that and I'll need to make adjustments so those work with this PR.

Issue is because I guard the legacy renderer from the use of the class attribute :/ But I think before merging this I'll try to add support to gen_stub and run a whole batch of these again. (Although IIRC DS does not use stub files yet within the extension)

@Girgias Girgias merged commit ac72a94 into master Jul 26, 2023
@Girgias Girgias deleted the approach-2-fix-classsynopsis branch July 26, 2023 13:10
@Girgias
Copy link
Member Author

Girgias commented Jul 26, 2023

@mallardduck merged this so feel free to fix the DS markup again. :)

@mallardduck
Copy link
Contributor

mallardduck commented Jul 26, 2023

@Girgias - does gen_stub need to still be updated and ran on things? If I follow correctly that should cover core PHP things but not extensions right?

Currently I am hitting the assertion you put in here:
https://github.com/php/phd/blob/master/phpdotnet/phd/Package/Generic/XHTML.php#L1009

It seems to be being caused by Traversable having the class attribute, but using the structure from my PRs method. So it needs to be updated to match the syntax you've sorted out for us. Howveer should I update those by hand too, or is that what gen_stub should cover?

@Girgias
Copy link
Member Author

Girgias commented Jul 26, 2023

@kocsismate is covering gen_stub, so don't worry about that.

No, you don't need to convert any classes that use the "old" rendering, the example changes I made for Traversable are just an example of the markup and I don't really indent on changing them as that is going to be a lot of churn for translation for the time being.

I would "just" change the interfaces for the time being to the new markup.

@Girgias
Copy link
Member Author

Girgias commented Jul 26, 2023

Also gen_stub can cover PECL extensions (as I did that for ibm_db2) but it needs stub files, which last time I checked DS did not have.

@mallardduck
Copy link
Contributor

Ok - so is it expected that I should see build errors currently then? I'm seeing:

php phd/render.php --docbook doc-base/.manual.xml --package PHP --format php
[14:15:25 - Rendering Style       ] Running full build
[14:15:25 - Indexing              ] Skipping indexing
[14:15:25 - Rendering Style       ] Running full build
[14:15:25 - Rendering Format      ] Starting PHP-Web rendering

Fatal error: Uncaught AssertionError: assert($this->cchunk['classsynopsis']['legacy'] === true) in /Users/danpock/GitProjects/the-php/phd/phpdotnet/phd/Package/Generic/XHTML.php:1009
Stack trace:
#0 /Users/danpock/GitProjects/the-php/phd/phpdotnet/phd/Package/Generic/XHTML.php(1009): assert(false, 'assert($this->c...')
#1 /Users/danpock/GitProjects/the-php/phd/phpdotnet/phd/Render.php(123): phpdotnet\phd\Package_Generic_XHTML->format_classsynopsisinfo(false, 'classsynopsisin...', Array, Array)
#2 /Users/danpock/GitProjects/the-php/phd/render.php(121): phpdotnet\phd\Render->execute(Object(phpdotnet\phd\Reader))
#3 {main}
  thrown in /Users/danpock/GitProjects/the-php/phd/phpdotnet/phd/Package/Generic/XHTML.php on line 1009

When I add a try-catch with good old dump-die, I see it's from Traversable:

array(23) {
  ["classsynopsis"]=>
  array(7) {
    ["close"]=>
    bool(false)
    ["classname"]=>
    string(11) "Traversable"

@Girgias
Copy link
Member Author

Girgias commented Jul 26, 2023

AHHH right I had forgotten those got updated to use your rendering >_> yeah those need to be fixed... I suppose let's just wait for @kocsismate to finish updating gen_stub so that we can fix those interfaces too

kocsismate added a commit to kocsismate/doc-en that referenced this pull request Jul 27, 2023
kocsismate added a commit to kocsismate/doc-en that referenced this pull request Jul 31, 2023
@Lewiscowles1986
Copy link

I Just rebased php/doc-en#2638 atop @kocsismate branch and it looks like the error still happens

Fatal error: Uncaught AssertionError: assert($this->cchunk['classsynopsis']['legacy'] === true) in /var/www/phd/phpdotnet/phd/Package/Generic/XHTML.php:1009
Stack trace:
#0 /var/www/phd/phpdotnet/phd/Package/Generic/XHTML.php(1009): assert(false, 'assert($this->c...')
#1 /var/www/phd/phpdotnet/phd/Render.php(125): phpdotnet\phd\Package_Generic_XHTML->format_classsynopsisinfo(false, 'classsynopsisin...', Array, Array)
#2 /var/www/phd/render.php(121): phpdotnet\phd\Render->execute(Object(phpdotnet\phd\Reader))
#3 {main}
  thrown in /var/www/phd/phpdotnet/phd/Package/Generic/XHTML.php on line 1009

Is there more work to do in #2611 or is there a way to make a branch from before this PR merged?

@Girgias
Copy link
Member Author

Girgias commented Aug 3, 2023

I Just rebased php/doc-en#2638 atop @kocsismate branch and it looks like the error still happens

Fatal error: Uncaught AssertionError: assert($this->cchunk['classsynopsis']['legacy'] === true) in /var/www/phd/phpdotnet/phd/Package/Generic/XHTML.php:1009
Stack trace:
#0 /var/www/phd/phpdotnet/phd/Package/Generic/XHTML.php(1009): assert(false, 'assert($this->c...')
#1 /var/www/phd/phpdotnet/phd/Render.php(125): phpdotnet\phd\Package_Generic_XHTML->format_classsynopsisinfo(false, 'classsynopsisin...', Array, Array)
#2 /var/www/phd/render.php(121): phpdotnet\phd\Render->execute(Object(phpdotnet\phd\Reader))
#3 {main}
  thrown in /var/www/phd/phpdotnet/phd/Package/Generic/XHTML.php on line 1009

Is there more work to do in #2611 or is there a way to make a branch from before this PR merged?

Are you sure you have the latest commits from doc-base, doc-en, and phd?

As I can render the docs without any issues.

Commands used from my phd clone:

php ../base/configure.php 
php render.php -d ../base/.manual.xml -P PHP -f xhtml -o ../output/

@Lewiscowles1986
Copy link

Lewiscowles1986 commented Aug 3, 2023

So I'm running from outside of the phd repo, but I am on master for phd, doc-base and doc-en.

This is also affecting another builder, who instead of highlighting was working around using a commit pin.

I can confirm that if I CD into phd, and copy-paste your commands I still get this error.

@Lewiscowles1986
Copy link

Lewiscowles1986 commented Aug 3, 2023

doc-en commit hash 184082814f268f881bf7834c5400e1981140d8ea (master HEAD)
doc-base commit hash 15be9f9b25fe4b4b553bd7aed973966ba8103f4e (master HEAD)
phpd commit hash 619c1c1a68dbc04c42e6b9216a61701a3b076a22 (master HEAD)

@Girgias
Copy link
Member Author

Girgias commented Aug 3, 2023

Can you change the:
assert($this->cchunk["classsynopsis"]["legacy"] === true); on line 1009 of phd/Package/Generic/XHTML.php to

if (!$this->cchunk["classsynopsis"]["legacy"] === true) { var_dump($name); }

This might give some info without needed to go through a debugger

@mallardduck
Copy link
Contributor

mallardduck commented Aug 3, 2023

@Girgias is this still waiting on @kocsismate to update gen_stub and rerun that? It seems a lot like what I reported last week.

@Girgias
Copy link
Member Author

Girgias commented Aug 3, 2023

@Girgias is this still waiting on @kocsismate to update gen_stub and rerun that? It seems a lot like what I reported last week.

It has been updated, and the interfaces have been updated. Just classes still use the "legacy" rendering for the most part, which is somewhat incompatible with the output as I want to let translation some time to catch up.

@Lewiscowles1986
Copy link

@kocsismate has not yet been merged, but I have done a 3 way branch including master, kocsismate and the new code, as well as tested this on just kocsismate and master. It would really help me to know which sha's are being used for the instructions above and if it works in a clean-install, or if there are maybe files or instructions I'm not following.

I Started this to troubleshoot if there was a nicer way to handle https://github.com/php/doc-en/pull/2638/files#diff-38801fa32c4bd7bd97aa3c87c138be36e126e0337b22aacf27ab57365357dc20R10 as I think being able to build from master, branch or tag (all of which I can clone shallow) would work.

The linked PR is not my work, but only works (same error as I've shown here) if pinning to a specific commit sha.

@mallardduck
Copy link
Contributor

@Lewiscowles1986 - looks like the current build errors are coming from DS needing to be updated for the new format. I'll send the follow up PR to update those for @Girgias syntax improvements.

@Lewiscowles1986
Copy link

Lewiscowles1986 commented Aug 3, 2023

Thanks all and sorry for creating such noise on a merged branch 👍 . I'd love to know what DS is?

@mallardduck
Copy link
Contributor

mallardduck commented Aug 3, 2023

@Girgias - sent a PR: php/doc-en#2641 to fix the DS docs. Seems to fix builds!

○ → php phd/render.php --docbook doc-base/.manual.xml --package PHP --format php
[13:56:40 - Rendering Style       ] Running full build
[13:56:40 - Indexing              ] Indexing...
[13:56:49 - Indexing              ] Indexing done
[13:56:49 - Rendering Style       ] Running full build
[13:56:49 - Rendering Format      ] Starting PHP-Web rendering
[13:57:07 - Rendering Format      ] Writing search indexes..
[13:57:07 - Rendering Format      ] Index written
[13:57:07 - Rendering Format      ] Finished rendering

@Lewiscowles1986 - just shorthand for Data Structures extension. https://www.php.net/manual/en/intro.ds.php

@Girgias
Copy link
Member Author

Girgias commented Aug 3, 2023

ACK currently not in front of a computer but will do it ASAP

Girgias pushed a commit to php/doc-en that referenced this pull request Aug 30, 2023
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.

3 participants