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

[docs] Migrate the Plugin_files page #69

Merged
merged 11 commits into from
Apr 28, 2022
Merged

Conversation

andrewnicols
Copy link
Member

No description provided.

@andrewnicols andrewnicols marked this pull request as draft April 25, 2022 05:14
@andrewnicols andrewnicols force-pushed the pluginFiles branch 5 times, most recently from 48dbd42 to 3fb08cc Compare April 27, 2022 14:23
@andrewnicols andrewnicols marked this pull request as ready for review April 27, 2022 14:24
@andrewnicols andrewnicols force-pushed the pluginFiles branch 2 times, most recently from d6fbe87 to 0cd99c0 Compare April 27, 2022 14:59
@andrewnicols
Copy link
Member Author

andrewnicols commented Apr 27, 2022

This issue needs a bit of explaining.

As I was moving some of the plugintype doumentation over I noticed that there is a lot of documentation relating to plugin files which is duplicated, or out-of-date. We often document files like version.php in plugintype docs, but each is different, with different levels of detail, etc.

To solve this I thought it would be useful to move these sections out into reusable templates, but then I realised that we sometimes want to specify extra information, differnt information, different examples, no examples, etc.

To solve this I created a ComponentFileSummary component which takes the key information required to generate a summary of a file, that is information including:

  • plugintype
  • pluginname
  • filepath
  • brief summary of purpose
  • example
  • description

We can use this data to create a consistent look and feel which is reusable.

The default description of the file is provided in an mdx file. Additional descripton data can be added using the extraDescription property, or entirely replaced with the description property.

Likewise a default example can be provided, but this can be modified from a specific plugintype.

Equally the plugintypecan be specified in a specific component type (e.g. antivirus) and the title showing the path to the file will be updated using data from the standad Mooodle components.json. For example, the common files shows information for a generic version.php, but the activity module docs adds its own using:

<VersionPHP
    plugintype='mod'
    pluginname='[modname]'
/>

Likewise the Antivirus documentaiton wishes to specify a better example for its settings.php. This can be achieved with:

export const settingsExample = `
if ($ADMIN->fulltree) {
    $settings->add(
        new admin_setting_configexecutable(
            'antivirus_scanmyfile/pathtoscanner',",
            new lang_string('pathtoscanner', 'antivirus_scanmyfile'),",
            new lang_string('configpathtoscanner', 'antivirus_scanmyfile'),",
            ''",
        )
    );
}
`;

<SettingsPHP
    plugintype="antivirus"
    pluginname="scanmyfile"
    example={settingsExample}
/>

The standard description will beu sed, but the example filename will have the path lib/antivirus/scanmyfile/settings.php. The lib/antivirus comes from the standard Moodle components.json and the plugintype="antivirus". The scanmyfile comes from pluginname, and the settings.php is specifeid in the generic antivirus settings as the default filename to use. The custom example is specified as an exported constant and passed into example.

In addition to this, the docs pages are version-speciifc so we should ues the components.json for the correct version.

This means that we do a little bit of currying and provide a default version of the getter in the /docs/_utils.tsx file which includes the version-speific helper, and other useful information.

@andrewnicols andrewnicols force-pushed the pluginFiles branch 2 times, most recently from d50cb84 to d02a985 Compare April 27, 2022 15:42
Copy link
Member

@sarjona sarjona left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this huge feature to simplify the creation of the plugin type pages! I think that's a great idea and, although the visualization can still be slightly improved, it's a very good improvement! Well done.

As you'll see, I've raised a few questions and sent some suggestions. Apart from that, I have one more comment, related to the way categories are displayed: as you can see in the following screenshot, content below each plugin type is not consistent (for instance, a couple of them are displaying the <Since xxx label):
plugintypes

docs/apis/_files/version-php.mdx Show resolved Hide resolved
docs/apis/_files/lang.mdx Outdated Show resolved Hide resolved
docs/apis/_files/lib.mdx Show resolved Hide resolved
docs/apis/_files/locallib.mdx Show resolved Hide resolved
docs/apis/_files/db-install-xml.mdx Outdated Show resolved Hide resolved
docs/apis/_files/db-access-php.tsx Outdated Show resolved Hide resolved
docs/apis/_files/pix-dir.mdx Show resolved Hide resolved
version.php Outdated Show resolved Hide resolved
docs/apis/plugintypes/qbank/index.mdx Show resolved Hide resolved
docs/apis/plugintypes/local/index.mdx Show resolved Hide resolved
@andrewnicols
Copy link
Member Author

As you'll see, I've raised a few questions and sent some suggestions.

I think I've resolved all but one of these appropriately. The final one is awaiting feedback from you re the question bank plugin type.

Apart from that, I have one more comment, related to the way categories are displayed: as you can see in the following screenshot, content below each plugin type is not consistent (for instance, a couple of them are displaying the <Since xxx label):

This is a bug in Docusaurus. I've asked on their Discord chat if there's an existing issue for it - waiting to hear back.

I'll rebase my code now (some conflicts to resolve) and then I'll update the patch.

Copy link
Member

@sarjona sarjona left a comment

Choose a reason for hiding this comment

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

Hi Andrew!
Thanks a lot for clarifying the raised points :-)
The patch looks good and I think it's ready to be merged. Besides, I've just seen the issue with the categories has been fixed too! <3
plugintypesfixed

@sarjona sarjona merged commit 23a8bda into moodle:main Apr 28, 2022
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