Skip to content

Allow setting a default language for literal blocks #608

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

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

wouterj
Copy link
Contributor

@wouterj wouterj commented Oct 1, 2023

Besides setting the local language using the .. highlight:: directive, Sphinx also allows specifying a global default language for literal blocks. We use this in Symfony to mark all literal blocks as "php".

After this PR, you can configure the default language in guides.xml:

    <extension class="phpDocumentor\Guides\RestructuredText"
        default-code-language="php"
    />

@linawolf
Copy link
Contributor

linawolf commented Oct 3, 2023

We do save the language in each LiteralInlineNode, which is already part of the guides. So why don't we make this part of the guides and Save it in the ProjectSettings? It is a useful feature for other input formats as well.

Also I think we should keep all Settings in the Settings Manager so that they are easy to find and not scattered throughout the project. We could make a way that extensions can save their setting objects in the settings Manager?

@wouterj wouterj force-pushed the default-highlight-language branch from a0dcb1d to d069510 Compare October 10, 2023 11:53
@wouterj
Copy link
Contributor Author

wouterj commented Oct 10, 2023

Good suggestions, I've moved the setting to ProjectSettings/guides.

@linawolf
Copy link
Contributor

I would suggest to add an integration test that demonstrates this setting. Integration tests do respect the guides.xml

@linawolf linawolf self-assigned this Oct 21, 2023
@linawolf
Copy link
Contributor

I am going to rebase this and see what I can do about the integration tests

@linawolf linawolf force-pushed the default-highlight-language branch from d069510 to 3f5aae9 Compare October 21, 2023 08:45
@linawolf
Copy link
Contributor

@wouterj could you have a look why the integration tests are not working?

@linawolf
Copy link
Contributor

Ah ok, I think I figured it out. it needs to be set as an argument of the guides tag now, however we need to change the description of your commit and the guides.xsd

@linawolf linawolf force-pushed the default-highlight-language branch from 359904b to 371b0c8 Compare October 21, 2023 08:56
@linawolf linawolf requested a review from jaapio October 21, 2023 09:08
@jaapio jaapio force-pushed the default-highlight-language branch from 0412acd to c7dad02 Compare October 23, 2023 17:33
@jaapio jaapio enabled auto-merge October 23, 2023 17:34
@jaapio jaapio merged commit 0aa0119 into phpDocumentor:main Oct 23, 2023
@wouterj wouterj deleted the default-highlight-language branch October 23, 2023 17:44
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.

4 participants