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

Prepare docs for generating the help config from them. #107

Closed
3 tasks done
SadieCat opened this issue Nov 17, 2021 · 1 comment
Closed
3 tasks done

Prepare docs for generating the help config from them. #107

SadieCat opened this issue Nov 17, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@SadieCat
Copy link
Member

SadieCat commented Nov 17, 2021

Some changes we need to make before this change:

  • Add an oper_only bool field to the commands section of the YAML.
  • Merge example_commands into the commands section under each module.
  • Convert the core command data from Markdown to YAML.
progval added a commit to progval/inspircd-docs that referenced this issue Nov 18, 2021
This should help with inspircdGH-107.

This does not change the HTML output, except for the removed
HTML comment (`<!-- This file contains a page fragment. Any changes will affect all pages that include it. -->`)

For the record, I used this script:

```
import glob
import pprint
import re
import textwrap

for filename in sorted(glob.glob("docs/3/commands/_*.md")):
    cmd_name = re.match("docs/3/commands/_cmd_(.*).md", filename).group(1)
    print(cmd_name)
    with open(filename) as fd:
        content = fd.read()
    m = re.match(r".*\n### `(?P<syntax>[^`]+)`\n+(?P<description>[^#]*)\n+(#### Example Usage\n+(?P<example>.*))?$", content, re.DOTALL | re.MULTILINE)
    pprint.pprint(m.groupdict())

    with open(f"docs/3/commands/_{cmd_name}.yml", "wt") as fd:
        fd.write(textwrap.dedent(
            f"""
            name: {cmd_name}
            syntax: >-
              {m.group("syntax")}
            description: |-
            """
        ).lstrip())

        fd.write(textwrap.indent(m.group("description"), "  "))

        if m.group("example"):
            fd.write("example: |-\n" + textwrap.indent(m.group("example"), "  "))
```

pls a manual edit to `_stats.yml` because the regexp could not handle the
extra subtitle
progval added a commit to progval/inspircd-docs that referenced this issue Nov 18, 2021
This should help with inspircdGH-107.

This does not change the HTML output, except for the removed
HTML comment (`<!-- This file contains a page fragment. Any changes will affect all pages that include it. -->`)

For the record, I used this script:

```
import glob
import pprint
import re
import textwrap

for filename in sorted(glob.glob("docs/3/commands/_*.md")):
    cmd_name = re.match("docs/3/commands/_cmd_(.*).md", filename).group(1)
    print(cmd_name)
    with open(filename) as fd:
        content = fd.read()
    m = re.match(r".*\n### `(?P<syntax>[^`]+)`\n+(?P<description>[^#]*)\n+(#### Example Usage\n+(?P<example>.*))?$", content, re.DOTALL | re.MULTILINE)
    pprint.pprint(m.groupdict())

    with open(f"docs/3/commands/_{cmd_name}.yml", "wt") as fd:
        fd.write(textwrap.dedent(
            f"""
            name: {cmd_name}
            syntax: >-
              {m.group("syntax")}
            description: |-
            """
        ).lstrip())

        fd.write(textwrap.indent(m.group("description"), "  "))

        if m.group("example"):
            fd.write("example: |-\n" + textwrap.indent(m.group("example"), "  "))
```

plus a manual edit to `_stats.yml` because the regexp could not handle the
extra subtitle
progval added a commit to progval/inspircd-docs that referenced this issue Nov 18, 2021
This should help with inspircdGH-107.

This does not change the HTML output, except for the removed
HTML comment (`<!-- This file contains a page fragment. Any changes will affect all pages that include it. -->`)

For the record, I used this script:

```
import glob
import pprint
import re
import textwrap

for filename in sorted(glob.glob("docs/3/commands/_*.md")):
    cmd_name = re.match("docs/3/commands/_cmd_(.*).md", filename).group(1)
    print(cmd_name)
    with open(filename) as fd:
        content = fd.read()
    m = re.match(r".*\n### `(?P<syntax>[^`]+)`\n+(?P<description>[^#]*)\n+(#### Example Usage\n+(?P<example>.*))?$", content, re.DOTALL | re.MULTILINE)
    pprint.pprint(m.groupdict())

    with open(f"docs/3/commands/_{cmd_name}.yml", "wt") as fd:
        fd.write(textwrap.dedent(
            f"""
            name: {cmd_name}
            syntax: >-
              {m.group("syntax")}
            description: |-
            """
        ).lstrip())

        fd.write(textwrap.indent(m.group("description"), "  "))

        if m.group("example"):
            fd.write("example: |-\n" + textwrap.indent(m.group("example"), "  "))
```

plus a manual edit to `_stats.yml` because the regexp could not handle the
extra subtitle
progval added a commit to progval/inspircd-docs that referenced this issue Nov 18, 2021
This should help with inspircdGH-107.

This does not change the HTML output, except for the removed
HTML comment (`<!-- This file contains a page fragment. Any changes will affect all pages that include it. -->`)

For the record, I used this script:

```
import glob
import pprint
import re
import textwrap

for filename in sorted(glob.glob("docs/3/commands/_*.md")):
    cmd_name = re.match("docs/3/commands/_cmd_(.*).md", filename).group(1)
    print(cmd_name)
    with open(filename) as fd:
        content = fd.read()
    m = re.match(r".*\n### `(?P<syntax>[^`]+)`\n+(?P<description>[^#]*)\n+(#### Example Usage\n+(?P<example>.*))?$", content, re.DOTALL | re.MULTILINE)
    pprint.pprint(m.groupdict())

    with open(f"docs/3/commands/_{cmd_name}.yml", "wt") as fd:
        fd.write(textwrap.dedent(
            f"""
            name: {cmd_name}
            syntax: >-
              {m.group("syntax")}
            description: |-
            """
        ).lstrip())

        fd.write(textwrap.indent(m.group("description"), "  "))

        if m.group("example"):
            fd.write("example: |-\n" + textwrap.indent(m.group("example"), "  "))
```

plus a manual edit to `_stats.yml` because the regexp could not handle the
extra subtitle
progval added a commit to progval/inspircd-docs that referenced this issue Nov 18, 2021
This should help with inspircdGH-107.

This does not change the HTML output, except for the removed
HTML comment (`<!-- This file contains a page fragment. Any changes will affect all pages that include it. -->`)

For the record, I used this script:

```
import glob
import pprint
import re
import textwrap

for filename in sorted(glob.glob("docs/3/commands/_*.md")):
    cmd_name = re.match("docs/3/commands/_cmd_(.*).md", filename).group(1)
    print(cmd_name)
    with open(filename) as fd:
        content = fd.read()
    m = re.match(r".*\n### `(?P<syntax>[^`]+)`\n+(?P<description>[^#]*)\n+(#### Example Usage\n+(?P<example>.*))?$", content, re.DOTALL | re.MULTILINE)
    pprint.pprint(m.groupdict())

    with open(f"docs/3/commands/_{cmd_name}.yml", "wt") as fd:
        fd.write(textwrap.dedent(
            f"""
            name: {cmd_name}
            syntax: >-
              {m.group("syntax")}
            description: |-
            """
        ).lstrip())

        fd.write(textwrap.indent(m.group("description"), "  "))

        if m.group("example"):
            fd.write("example: |-\n" + textwrap.indent(m.group("example"), "  "))
```

plus a manual edit to `_stats.yml` because the regexp could not handle the
extra subtitle, and added newlines at the end of files missing one.
progval added a commit to progval/inspircd-docs that referenced this issue Nov 18, 2021
This allows to programmatically know which example demonstrates each command,
which will be used to generate HELPOP files (inspircdGH-107)
SadieCat pushed a commit that referenced this issue Nov 20, 2021
This allows to programmatically know which example demonstrates each command,
which will be used to generate HELPOP files (GH-107)
@SadieCat
Copy link
Member Author

Done.

@SadieCat SadieCat added the enhancement New feature or request label Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant