Is your feature request related to a problem? Please describe.
Within a large lecture series it can be a pretty common pattern to re-use code in different documents. In the past we have used literalinclude to bring in code from a file. As sphinx parses code eventually in the literal_block method it works pretty well.
The issue with myst_nb/jupyter-book is this no longer works when building in this context as the literalinclude is not brought in until sphinx is called. This means the code won't get executed at the jupyter_cache level as the literalinclude is contained in the markdown block when converting using jupytext. The code will be visible in the end HTML but not executed prior to building with sphinx.
Describe the solution you'd like
A solution to this would be to add :file: option to code-cell directives for including code that is meant to be executed.
```{code-cell} python3
:file: _code/code.py
```
Typically file type attributes are usually arguments in sphinx but I think it would be better in this case to retain the simplicity of optional language argument.
The more typical sphinx approach would be
```{code-cell} _code/code.py
```
Describe alternatives you've considered
None -- changing the behaviour of literalinclude to be parsed as code is not a viable solution given out jupytext works.
Additional context
This is currently an issue for migrating the python.quantecon.org series as literalincludes are used pretty extensively in 6 lectures. We could copy the code across these lectures but would prefer not to do that to assist with maintaining the code and consistency across lectures that use the same code.
Is your feature request related to a problem? Please describe.
Within a large lecture series it can be a pretty common pattern to re-use code in different documents. In the past we have used
literalincludeto bring in code from a file. Assphinxparsescodeeventually in theliteral_blockmethod it works pretty well.The issue with
myst_nb/jupyter-bookis this no longer works when building in this context as theliteralincludeis not brought in untilsphinxis called. This means the code won't get executed at thejupyter_cachelevel as theliteralincludeis contained in the markdown block when converting usingjupytext. The code will be visible in the endHTMLbut not executed prior to building with sphinx.Describe the solution you'd like
A solution to this would be to add
:file:option tocode-celldirectives for including code that is meant to be executed.Typically
filetype attributes are usually arguments insphinxbut I think it would be better in this case to retain the simplicity of optionallanguageargument.The more typical sphinx approach would be
Describe alternatives you've considered
None -- changing the behaviour of
literalincludeto be parsed as code is not a viable solution given outjupytextworks.Additional context
This is currently an issue for migrating the python.quantecon.org series as
literalincludesare used pretty extensively in 6 lectures. We could copy the code across these lectures but would prefer not to do that to assist with maintaining the code and consistency across lectures that use the same code.