sphinx-tabs icon indicating copy to clipboard operation
sphinx-tabs copied to clipboard

Support having the same content in multiple grouped tabs without duplicating it

Open guyikcgg opened this issue 4 years ago • 4 comments

It's common to have the same contents in multiple grouped tabs. Consider the following example:

.. group-tab:: Linux

    Copy the files using ``cp``.

.. group-tab:: Mac

    Copy the files using ``cp``.

.. group-tab:: Windows

    Copy the files using ``copy``.

It would be nice to have a way of not duplicating the same line in Linux and Mac.

guyikcgg avatar Apr 22 '20 14:04 guyikcgg

Ah, so something like allowing tab directives to properly support .. include:: directives and/or sphinx/rst substitutions within them?

I haven't tested those out within tab directives just yet, so I don't know what functionality works or is ignored, but these would seem like the ones to work on introducing support for.

ScriptAutomate avatar Aug 20 '20 05:08 ScriptAutomate

I'd reckon maybe something like:

.. group-tab:: Linux
    :duplicate: Mac; Other1; Other2

    Copy the files using ``cp``.

.. group-tab:: Windows

    Copy the files using ``copy``.

chrisjsewell avatar Aug 20 '20 05:08 chrisjsewell

I've used and I'm still using the include:: directive for duplicated content, it makes also code more readable and maintainable, plus you can reuse content also outside tabs.

BTW, @chrisjsewell thanks for picking the project up, although a bit too late for me... :-)

stefanodavid avatar Aug 24 '20 06:08 stefanodavid

@stefanodavid thanks for providing that workaround. I think it's really useful and will definitely try it out. However, for short documents or short commands inside the tab, I believe that @chrisjsewell 's proposal can be convenient.

@chrisjsewell, feel free to email me when you implement the feature -- I can help with documenting it.

guyikcgg avatar Aug 24 '20 10:08 guyikcgg