> I wrote an extension that allows users to create directives according
> reStructuredText template.
>
> In this case, you can create a wrapper directive like "code-block2",
> and the wrapper generates a real "code-block" with fixed caption and
> linenos flag.
>
> conf.py::
>
> from sphinxnotes.any import Schema, Field as F
>
> extensions = ['sphinxnotes.any']
>
> any_schemas = [
> Schema('code-block2',
> attrs={'language': F(referenceable=True)},
> content=F(form=F.Form.LINES),
> description_template='''
> .. code-block:: {{ language }}
> :caption: Your fixed caption
> :linenos:
>
> {% for line in content %}{{ line }}
> {% endfor %}'''),
> ]
>
> in your documentation::
>
> .. code-block2::
> :language: python
>
> print('hello, world!')
>
> For more details, please check
https://github.com/sphinx-notes/any
Markdown. But you gave me the idea: creating a custom directive.