executablebooks / sphinx-tabs

Tabbed views for Sphinx
https://sphinx-tabs.readthedocs.io
MIT License
263 stars 67 forks source link

Support for `include` directive in tabs #172

Closed JSS95 closed 1 year ago

JSS95 commented 1 year ago

Context

Sphinx's include directive allows including the entire code from another file.

.. include:: my/code.py
   :code: python

It would be nice if we had this feature in code tabs.

Proposal

Propsal A: allow include nested in code-tab

.. tabs::

   .. code-tab::

      .. include:: my/code.py
         :code: python

Proposal B: add :include: option to code-tab

.. tabs::

   .. code-tab::
      :include: my/code.py

Tasks and updates

No response

welcome[bot] commented 1 year ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

foster999 commented 1 year ago

Thanks for getting in touch!

Please could you try using 'include' within a normal 'tab' directive, instead of a 'code-tab'?

The 'code-tab' puts all of the content within a code block, which can't be nested in. I believe that 'include' creates its own code block, so using it in a normal tab should give the desired result. Please let me know if this doesn't work 😄

JSS95 commented 1 year ago

Thank you, @foster999. That worked! I think it would be good to have this documented so I opened #173.