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

Release Moodle 4.1 docs #473

Merged
merged 5 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
ignorePatterns: [
// Ignore code examples.
'docs/**/_examples/*',
'versioned_docs/*/**/_examples/*',
'general/**/_examples/*',
'!.markdownlint',
'!.lintstagedrc.mjs',
Expand Down
43 changes: 21 additions & 22 deletions config/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
const VersionsArchived = require('../versionsArchived.json');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const ArchivedVersionsDropdownItems = Object.entries(VersionsArchived).splice(
0,
5,
Expand Down Expand Up @@ -53,27 +52,27 @@ const navbar = {
},

// Right.
// {
// type: 'docsVersionDropdown',
// position: 'right',
// dropdownActiveClassDisabled: true,
// dropdownItemsAfter: [
// ...ArchivedVersionsDropdownItems.map(
// ([versionName, versionUrl]) => ({
// label: versionName,
// href: versionUrl,
// }),
// ),
// {
// href: 'https://docs.moodle.org/dev/',
// label: 'Legacy documentation',
// },
// {
// to: '/versions',
// label: 'All versions',
// },
// ],
// },
{
type: 'docsVersionDropdown',
position: 'right',
dropdownActiveClassDisabled: true,
dropdownItemsAfter: [
...ArchivedVersionsDropdownItems.map(
([versionName, versionUrl]) => ({
label: versionName,
href: versionUrl,
}),
),
{
href: 'https://docs.moodle.org/dev/',
label: 'Legacy documentation',
},
{
to: '/versions',
label: 'All versions',
},
],
},
],
};

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/javascript/yui/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tags:
- YUI
---

import DeprecatedSince from '../../../../src/components/DeprecatedSince';
import DeprecatedSince from '@site/src/components/DeprecatedSince';

<DeprecatedSince versions={["2.9"]} />

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/javascript/yui/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tags:
- YUI
---

import DeprecatedSince from '../../../../src/components/DeprecatedSince';
import DeprecatedSince from '@site/src/components/DeprecatedSince';

<DeprecatedSince versions={["2.9"]} />

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/javascript/yui/namespacing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tags:
- YUI
---

import DeprecatedSince from '../../../../src/components/DeprecatedSince';
import DeprecatedSince from '@site/src/components/DeprecatedSince';

<DeprecatedSince versions={["2.9"]} />

Expand Down
7 changes: 3 additions & 4 deletions docs/intro.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
id: introduction
title: Introduction
description: Developer documentation for Moodle 4.0.
description: Developer documentation for Moodle 4.2.
slug: /
tags:
- Getting started
---

Welcome to the Developer Documentation for **Moodle 4.0**.
Welcome to the Developer Documentation for **Moodle 4.2**.

This documentation is version-specific and includes a range of useful guides and information.

Expand All @@ -16,8 +16,7 @@ This documentation is version-specific and includes a range of useful guides and
- If you're new to Moodle development, you should check out our [Getting started guide](/general/development/gettingstarted)
- Look through our [guides to Moodle APIs](./apis.md)
- Browse our [Moodle feature](./guides.md) deep dives
- You may want to read the [Release notes](/general/releases/4.0) for Moodle 4.0
- Have a plugin that you want to prepare for Moodle 4.0, check out the [Developer update notes](./devupdate.md)
<!--- You may want to read the [Release notes](/general/releases/4.2) for Moodle 4.2-->
- Interested in supporting the Moodle App in your plugins? Read the [Moodle App documentation](/general/app)

:::
2 changes: 2 additions & 0 deletions sidebars/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ const sidebars = {
},
},

/*
{
label: 'Developer update',
type: 'doc',
id: 'devupdate',
},
*/

{
label: 'Moodle App',
Expand Down
120 changes: 120 additions & 0 deletions versioned_docs/version-4.1/_utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/**
* Copyright (c) Moodle Pty Ltd.
*
* Moodle is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Moodle is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Moodle. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { type ReactNode } from 'react';
import ComponentFileSummaryGeneric, {
type ComponentFileSummaryProps,
} from '@site/src/components/ComponentFileSummary';
import { MDXProvider } from '@mdx-js/react';

import { getExample } from '@site/src/moodleBridge';

export {
getExample,
ComponentFileSummaryProps,
};

/**
* Fill the default properties.
* @param {Props} props
* @return {Props}
*/
export const fillDefaultProps = (props: ComponentFileSummaryProps): ComponentFileSummaryProps => ({
filetype: 'php',
examplePurpose: props.summary,
...props,
});

const normaliseDescription = (Value: ReactNode | string): null | JSX.Element => {
if (typeof Value === 'boolean' || !Value) {
return null;
}

if (typeof Value === 'string' || React.isValidElement(Value)) {
return (
<MDXProvider>
{Value}
</MDXProvider>
);
}

return (
<MDXProvider>
<Value />
</MDXProvider>
);
};

/**
* Get the preferred description given a standard properties value which contains an optional description,
* and/or extraDescription, and a DefaultDescription object.
*
* @param {Props} props
* @param {DefaultDescription} DefaultDescription The default description to use if the `description` property is empty
* @returns {MDXLayout}
*/
export const getDescription = ({
description = null,
extraDescription = null,
children = null,
}: ComponentFileSummaryProps, defaultDescription?: ReactNode | string): null | ReactNode | JSX.Element => {
if (children) {
const Description = normaliseDescription(children);
return (
<MDXProvider>
{Description}
</MDXProvider>
);
}

if (description) {
const Description = normaliseDescription(description);
return (
<MDXProvider>
{Description}
</MDXProvider>
);
}

const Description = normaliseDescription(defaultDescription);
const ExtraDescription = normaliseDescription(extraDescription);

if (Description) {
return (
<MDXProvider>
{Description}
{ExtraDescription}
</MDXProvider>
);
}

return null;
};

export const ComponentFileSummary = (initialProps: ComponentFileSummaryProps): JSX.Element => {
const props = fillDefaultProps({
examplePurpose: initialProps?.summary ?? null,
...initialProps,
});

props.description = getDescription(props, props?.defaultDescription ?? null);

if (props?.example || props?.defaultExample) {
props.example = getExample(props, props?.defaultExample ?? null);
}

return ComponentFileSummaryGeneric(props);
};
Loading