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: add Pygments lexer for Ansible output #50318

Merged
merged 3 commits into from Jan 3, 2019

Conversation

felixfontein
Copy link
Contributor

SUMMARY

Adds Pygments lexer for Ansible output (with default output plugin). Fixes #50040. The example from the issue will be formatted like this:

ansible-output-1

CC @acozine @gundalow @dagwieers

ISSUE TYPE
  • Docs Pull Request
COMPONENT NAME

docs.ansible.com

ADDITIONAL INFORMATION

Some results of some more random Ansible output (taken from docs and PRs). Uses the default colorful style, i.e. not the Ansible colors; it mainly shows that other stuff is also lexed correctly :)

ansible-output-2

@ansibot
Copy link
Contributor

ansibot commented Dec 26, 2018

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

docs/docsite/_extensions/pygments_lexer.py:497:9: E266 too many leading '#' for block comment
docs/docsite/_extensions/pygments_lexer.py:547:9: E266 too many leading '#' for block comment

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 ci_verified Changes made in this PR are causing tests to fail. docs This issue/PR relates to or includes documentation. docsite This issue/PR relates to the documentation website. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Dec 26, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Dec 26, 2018
@dagwieers
Copy link
Member

I personally prefer the GitHub colouring, and we made sure that the previous lexer was using the GitHub colourset

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Dec 26, 2018
@felixfontein
Copy link
Contributor Author

@dagwieers do you mean for the JSON? For everthing else, I find the GitHub coloring somewhat ugly (see here for the diff examples as highlighted by GH).

@felixfontein
Copy link
Contributor Author

Actually, the GH coloring for JSON looks pretty boring. Are you sure you want that?

{
    "account": {
        "account_name": "vagrant-domain",
        "domain_name": "DOMAIN",
        "sid": "S-1-5-21-3088887838-4058132883-1884671576-1105",
        "type": "User"
    },
    "authentication_package": "Kerberos",
    "changed": false,
    "dns_domain_name": "DOMAIN.LOCAL",
    "groups": [
        {
            "account_name": "Administrators",
            "attributes": [
                "Mandatory",
                "Enabled by default",
                "Enabled",
                "Owner"
            ],
            "domain_name": "BUILTIN",
            "sid": "S-1-5-32-544",
            "type": "Alias"
        },
        {
            "account_name": "INTERACTIVE",
            "attributes": [
                "Mandatory",
                "Enabled by default",
                "Enabled"
            ],
            "domain_name": "NT AUTHORITY",
            "sid": "S-1-5-4",
            "type": "WellKnownGroup"
        },
    ],
    "impersonation_level": "SecurityAnonymous",
    "label": {
        "account_name": "High Mandatory Level",
        "domain_name": "Mandatory Label",
        "sid": "S-1-16-12288",
        "type": "Label"
    },
    "login_domain": "DOMAIN",
    "login_time": "2018-11-18T20:35:01.9696884+00:00",
    "logon_id": 114196830,
    "logon_server": "DC01",
    "logon_type": "Interactive",
    "privileges": {
        "SeBackupPrivilege": "disabled",
        "SeChangeNotifyPrivilege": "enabled-by-default",
        "SeCreateGlobalPrivilege": "enabled-by-default",
        "SeCreatePagefilePrivilege": "disabled",
        "SeCreateSymbolicLinkPrivilege": "disabled",
        "SeDebugPrivilege": "enabled",
        "SeDelegateSessionUserImpersonatePrivilege": "disabled",
        "SeImpersonatePrivilege": "enabled-by-default",
        "SeIncreaseBasePriorityPrivilege": "disabled",
        "SeIncreaseQuotaPrivilege": "disabled",
        "SeIncreaseWorkingSetPrivilege": "disabled",
        "SeLoadDriverPrivilege": "disabled",
        "SeManageVolumePrivilege": "disabled",
        "SeProfileSingleProcessPrivilege": "disabled",
        "SeRemoteShutdownPrivilege": "disabled",
        "SeRestorePrivilege": "disabled",
        "SeSecurityPrivilege": "disabled",
        "SeShutdownPrivilege": "disabled",
        "SeSystemEnvironmentPrivilege": "disabled",
        "SeSystemProfilePrivilege": "disabled",
        "SeSystemtimePrivilege": "disabled",
        "SeTakeOwnershipPrivilege": "disabled",
        "SeTimeZonePrivilege": "disabled",
        "SeUndockPrivilege": "disabled"
    },
    "rights": [
        "SeNetworkLogonRight",
        "SeBatchLogonRight",
        "SeInteractiveLogonRight",
        "SeRemoteInteractiveLogonRight"
    ],
    "token_type": "TokenPrimary",
    "upn": "vagrant-domain@DOMAIN.LOCAL",
    "user_flags": []
}

@felixfontein
Copy link
Contributor Author

I adjusted the tokens a bit, to make the output more similar to the faux YAML output from the linked page. Now it looks like this (I've used the Ansible CSS for the random output from above):

ansible-output-3

@dagwieers
Copy link
Member

I like it more than the red/green we had before!

Copy link
Member

@dagwieers dagwieers left a comment

Choose a reason for hiding this comment

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

LGTM

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed core_review In order to be merged, this PR must follow the core review workflow. labels Dec 28, 2018
@acozine acozine added this to To do in OLD Ansible Documentation via automation Jan 2, 2019
@samccann samccann merged commit 9657a21 into ansible:devel Jan 3, 2019
@samccann
Copy link
Contributor

samccann commented Jan 3, 2019

Thanks @felixfontein for the fix!

@felixfontein felixfontein deleted the docs-format-ansible-output branch January 3, 2019 16:38
@felixfontein
Copy link
Contributor Author

@dagwieers thanks for your review!
@samccann thanks for merging!

kbreit pushed a commit to kbreit/ansible that referenced this pull request Jan 11, 2019
* Add specialized lexer for Ansible output.

* Make linter happy.

* Use different tokens.
@acozine acozine moved this from To do to Backport to 2.7 in OLD Ansible Documentation Jan 28, 2019
acozine pushed a commit to acozine/ansible that referenced this pull request Jun 25, 2019
* Add specialized lexer for Ansible output.

* Make linter happy.

* Use different tokens.

(cherry picked from commit 9657a21)
acozine pushed a commit to acozine/ansible that referenced this pull request Jun 25, 2019
* Add specialized lexer for Ansible output.

* Make linter happy.

* Use different tokens.

(cherry picked from commit 9657a21)
acozine added a commit that referenced this pull request Jun 25, 2019
* Add specialized lexer for Ansible output.

* Make linter happy.

* Use different tokens.

(cherry picked from commit 9657a21)
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 docs This issue/PR relates to or includes documentation. docsite This issue/PR relates to the documentation website. shipit This PR is ready to be merged by Core support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs code-blocks of task/playbook output should not get err class
4 participants