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

Native directive params support #55

Open
mvorisek opened this issue Jul 14, 2023 · 3 comments
Open

Native directive params support #55

mvorisek opened this issue Jul 14, 2023 · 3 comments

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Jul 14, 2023

I am migrating sphinx docs from .rst to .md.

Rst file:

.. php:method:: add($object, $region = 'Content')

    Bla bla

    :param $object: Xxx

Md/MyST file:

:::{php:method} add($object, $region = 'Content')
:param $region: Xxx

Bla Bla

:param $object: Xxx
:::

Currently the output looks like:
image

Notice, the native MyST param is missing/ignored and the 2nd param not parsed [1]/formated. I think the problem is sphinxcontrib-phpdomain extension tries to parse the params from rst text directly instead of supporting directive/AST params directly.

[1] MyST spec https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#parameterizing-directive - directives are parsed at the directive start only

I would expect sphinxcontrib-phpdomain extension to honor natively parsed directive parameters.

Sphinx build log:

C:\Users\Administrator\Desktop\md\docs\view.md:46: WARNING: 'php:method': Unknown option keys: ['param $region']
    (allowed: ['module', 'nocontentsentry', 'noindex', 'noindexentry']) [myst.directive_parse]

To reproduce this issue, edit any rst sphinx project like:

conf.py:

 extensions = [
     'sphinx.ext.autodoc',
     'sphinx.ext.intersphinx',
     'sphinx.ext.todo',
     'sphinx.ext.coverage',
     'sphinxcontrib.phpdomain',
+    'myst_parser',
 ]

+myst_enable_extensions = ['colon_fence']

requirements.txt

 sphinx<5
 sphinx-rtd-theme
 sphinxcontrib-phpdomain
+myst-parser
@mvorisek mvorisek changed the title PHP params and MyST Native directive params support Jul 14, 2023
@markstory
Copy link
Owner

I have no context on alternative parsers for sphinx, and won't be able to support them well. You'd need to submit a pull request with some form of regression tests in order to get support for this use case added.

@mvorisek
Copy link
Contributor Author

For classes I would also expect attributes like "extends", "implements", ex:

:::{php:class} Car
:extends: ObjectModel
:implements: JsonSerializable
:implements: Iterator

Car class that can be serialized to JSON and iterated.
:::

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

No branches or pull requests

2 participants