Changes to Joomla manual examples to support lazy loading of plugins#52
Changes to Joomla manual examples to support lazy loading of plugins#52robbiejackson wants to merge 1 commit intojoomla:mainfrom
Conversation
|
I would show only code for specific version. Latest would be:
Not really. I would avoid |
|
The problem is that while the Joomla manual does support different versions, the manual examples repo (currently) doesn't. So, for example, in the manual we have the plugin tutorial at https://manual.joomla.org/docs/building-extensions/plugins/basic-content-plugin/ and this page has a link to the plugin tutorial code in the manual examples repo - ie it has the link https://github.com/joomla/manual-examples/tree/main/plugin-example-shortcode This link is the same no matter what version you've selected within the manual. So let's say we have the code in the manual-examples repo set to be the latest code, using the Then an extension developer is reading the manual version 4.4 documentation because he has to write a plugin that works under Joomla 4.4. He looks at the plugin tutorial page, follows the link to the manual-examples repo and installs the plugin-example-shortcode on his test Joomla 4.4 instance. It will obviously crash because the DI container has no This is what we need to avoid. The alternative to switching on JVERSION is to have multiple versions of plugin-example-shortcode in the manual-examples repo, and have different links to them. For example on https://manual.joomla.org/docs/building-extensions/plugins/basic-content-plugin/: For the 4.4 page link to https://github.com/joomla/manual-examples/tree/main/plugin-example-shortcode-4-4 For the 6.0 page link to https://github.com/joomla/manual-examples/tree/main/plugin-example-shortcode-6-0 I'm ok to do this if you think that would be better, but it does feel like a bigger maintenance overhead. I recognise that the code with the JVERSION logic looks complex. But on the other hand it does make it clear to extension developers what they need to consider - in general they will be looking to develop an extension that runs on multiple versions of Joomla, so this information is useful for them, and actually may be the way they decide to code their extension. |
|
I fully understand your concerns about supporting multiple versions, but to be realistic, if you want to learn how to create a new plugin, you don't care about b/c. If you like to create extensions for multiple versions we should have a section explaining how to use the JVERSION constant. For different plugin tutorial version we should different branches, we have for the cms and the framework already a url schema: cms-api:// and framework-api:// which we can extend for the example repository: example:// https://github.com/joomla/manual-examples/tree/<JVERSION_MINOR_OR_ONLY_MAJOR>/plugin-example-shortcode this would allow people to easily compare j4 version of the plugin with j6 version directly in github. what this be acceptable for you? |
|
OK, so I believe you're saying that having different versions of the plugin in the repo would be better. Let me work on that approach and push another commit ... |
I am sorry, I totally missed that it is not Manual repo 😄
Well, I think it should not be that complicated. For the 4.4: https://github.com/joomla/manual-examples/tree/4.4/plugin-example-shortcode I think that should be a good path. upd: I think I wrote the same what @HLeithner wrote :) |
|
OK, is this a workable approach using git branches? I'll take the example of wanting to change the plugin tutorial example for 6.1, in order to use lazy plugins. We really only need 2 versions for this - make the change to drop the dispatcher parameter in the constructor at the same time as implementing the lazy plugin, ie 6.1. So to do this, first create a branch on the joomla repo called something like "up-to-6.0" so that this would be the same as the "main" branch at this point. Then make the changes for lazy plugins (and removal of dispatcher in constructor parameters) and merge into the main branch. In the manual for the plugin tutorial on version 6.1, point to the main branch In the manual for the plugin tutorial on version 6.0, 5.4, 4.4 etc point to the up-to-6.0 branch However in the manual for all the other examples, continue to point to the main branch. So the up-to-6.0 branch is really just for exceptions, where the new code in 6.1 won't work on previous versions. If we put a new extension into the manual-examples repo, then it needs to be visible to all versions. This is where the requirements for the manual-examples repo differs from the requirements for the joomla cms repo. If we always used a named version branch (eg in the manual for version 4.4 linking always to a 4.4 branch in the manual-examples repo) then we'd have to merge the new extension code into each of the 4.4, 5.4, 6.0 etc branches. Too complex. So this is why I'm suggesting we just use the main branch, and point everything at it (as we do now), and have other branches just for exceptional cases. What do you think? |
|
Hm, not really like that. The branch should be for "starting from version X" not "up to version X". Example currently the main branch collects examples that works from 4.x, and from 5.x and from 6.0. When in future need to fix some comments etc, do fix in the main branch and then up-merge changes to 6.1 (and 7.x etc). In the manual the old documentation will still point on main branch (that is valid for that versions), and only newest will point to 6.1. Then for example, when will be released 6.5 then the documentation still will point on "6.1 of examples". When will be another big changes, example in 7.3, then create a new "7.3 of examples". Old branches will stay for old manuals, and new manual will use new branch. And so on. Unless I missing something. |
|
I think we may be suggesting the same thing, and the only difference is how we have named the branches. So after 6.1 the branches would be:
After 7.3 the branches would be:
I just prefer the aspect of always merging new stuff into the main branch. I think that's simpler for contributors - they just have to sync the main branch, and check out new branches from main etc. It also avoids any confusion in the mind of contributors - eg if they're developing documentation for version 7.1 and adding an example, they may be wondering why they should be working with the 6.1 branch. |
|
Well yes. But in the way how git is working I am not very imagine how it can work easily. Also this would means that you have to edit Manual page for older versions which is another extra work. I think it is better to avoid an extra work here. In the github it is possible to set "default branch". Currently it is "main" in future it can be "6.1". |
|
I'm afraid I disagree!
As I said, I believe we're talking about the same solution, but just labelling the branches differently. So if you had to rename the branches with one scheme you'd have to do it with the other. (But I don't believe you need to rename the branches anyway).
No you don't need to update all the links, you just update the links for the extension which is affected. So in the case of lazy plugins you'd just update the links for those pages which reference the plugin tutorial, for versions prior to 6.1. For all the other extensions in the examples repo they're pointed at using the main branch, and they just continue to use that. In fact, you'd need to do a lot more updating of links in the manual if we went with your scheme. For example, say there was a missing bracket in the module tutorial and that needed to be fixed. If we're using a 6.1 branch then the fix would get merged into 6.1. Then all the links from the manual would need to be updated from pointing to main to pointing to 6.1. And then if there was another fix in 7.3 you'd need to update all those links again from 6.1 to 7.3. So pretty much any change to existing examples would need to have links updated, or at the least, you'd need to check if they need to be updated. As the links are scattered through the manual this would involve a lot of work. If you're going with my scheme where the branch you're merging into is main, then none of the links need to be updated when you make a change like this. It's much better to go with a scheme where links don't need to be updated, because people are always going to forget to update them properly.
Well, I reckon they would usually go from the link in the manual, and that link has the branch within it. But it's not just that. It's to make it as easy as possible for contributors as well. For example, at the moment on my local PC I do: and then I'm always merging into main. If you're merging into 6.1 then you have to do and remember which is the current default branch, which someone can change and other contributors can be unaware of the change. I reckon most documentation contributors are like me and don't do a lot of development, and are far from being git experts. So the whole process needs to be as straightforward as possible. I think I've talked myself to a position where whatever solution we adopt we have to continue having main as the default branch which we're merging new stuff into. That makes it easiest for contributors, and minimises the amount of updating of links in the manual. |
|
About the renaming in the manual, that would not be needed if we match branch name with version in the manual and preserve all minor versions. Then we do the same as for the framework api using instead of this has a little maintainance overhead which means creating a new branch from the current default branch when we release a new docs version for 6.1 for example. This took 2 minutes, not really relevant when I out branch the new manual version. Advantages:
Disadvantages:
The only thing what never changes or better does it automatically is the link in the manual to the corresponding branch/version. |
Yes, for latest documentation the renaming will not be needed. Will show links to "main" where is the code already updated for latest 6.1 version.
Yes, that will work. I just not sure if we need a branch for each version. |
not really, because we only have max 4 branches at the same time we support (active versions)
|
|
Using the For example, if you're fixing a typo and that is then merged into branch 7.1 how does And you'd need to do the same if you wanted to include a new extension in the manual examples repo, as it would be merged into the latest branch, and not visible on older branches if you didn't merge it in there as well. Merging all the changes into multiple branches is a route that I'm not prepared to go down. I can understand that your guys' experience with the Joomla CMS and its version numbering tends to lead you down a route like that here. However, it just makes it all too complex. And it's a different problem we're trying to solve. Up until now we have been using just the main branch on the manual examples repo and that has worked really well. The process for contributing is straightforward and the links don't change for different versions. This will continue to be the case for > 99% of all of the code, so let's just keep it that way, and use separate branches just for exceptional cases. I really don't mind what these exceptional branches are called. But overall, please just let's keep it simple. |
The reason you made this PR is that we are reaching the limit of this approach 😉 It is possible to use
I totally understand, everyone hate it 😄
The thing that we have to crate branch in The main work need to be done in
In both cases we do not need to do anything in the Manual, except update link like Third way would be to branch out "up to X.Y" in example repo, as you suggested, and still keep "main" for latest version. But here I not sure how to update all that in Manual, because our Docusaurus script is dumb and do not know if external repository exist or not, it just know the Manual version, and even if it know how do we handle it hmhm. Maybe any other ideas? |
|
Oh, and the way 2.1 : |
I'm starting to document more fully the lazy plugin aspect.
This leads us into having different code for different versions of Joomla, and we need to agree in general how to document this within the Joomla manual examples repository.
I believe that any code in the manual examples repo should work for all the versions which are maintained in the Joomla manual, so at the moment that would be 4.4, 5.4, 6.0 and 6.1.
I've been thinking about the best way to handle these version-specific code sections and have proposed this PR, which is now up for review.
While the code in the manual examples repository needs to have the switch on JVERSION, I would propose NOT having this in the manual - so in the manual the particular document version would just have the code appropriate to that Joomla version.
For example at https://manual.joomla.org/docs/building-extensions/plugins/basic-content-plugin/ it would just show the services/provider.php file for that version alone.
I've also put comments for each version change which have links to the Joomla code changes. I'm not sure that everyone will want to look at these, but there are probably some people who will, and having this makes it easy for them.
Instead of having the version if/then statement at the
$container->set()level we could have it inside theset()to show finer granularity on the differences between 4.4 and 5.3 - egI think that might be clearer - but let me know what you think.