Skip to contentSkip to conversation

adding some semantic markup back into .rst files

DISCUSSION Robert P. J. Day 2 participants 3 messages Nov 1, 2020

lore
Share & tools
lore
#0 lore raw

one of the things that i liked about docbook was the semantic markup
that could be customized for individual tags, such that a <filename> could be rendered differently from a <command> using XSLT stylesheets and so on. at the moment, things like that are all lumped together in the .rst files by marking them up with ``blah`` double backquotes, losing all that distinction. it wouldn't be hard to put back just a *little* of those semantics by using the more obvious roles.

there are two roles for marking up commands:

:command:
:program:

the distinction appears to be that a :command: is meant to represent an OS-level command to be typed literally, such as "ls" or "rm". OTOH, a :program: should represent an executable program whose name could differ based on the OS, so that you would type:

:program:sphinx-build

even if the actual name of the program on Windows was "sphinx-build.exe"; that is what i would think you would use to mark up, say, :program:devtool upgrade. currently, there doesn't appear to be any difference in the rendering, but it at least leaves open the possibility for the future, and in terms of possibly cross-referencing commands.

a third role i think would be useful is :dfn: which is used to mark
the "defining instance" of a term -- it appears to be equivalent to docbook's "firstterm" tag. this does *not* automatically generate an index entry, but i suspect it could be used for exactly that if one wanted.

finally, there is :file: for filenames, which currently is being
rendered the same as marking up with ``, but has the additional cool feature that, if you use {...} in a filename, what is inside the {} is rendered as docbook's equivalent of "replaceable", to show that it is meant to be filled in (currently rendered as bold italic). as an example of that, in the dev-manual (common tasks section), section 3.5.2, there is the expression:

  ``${BUILDDIR}/conf/bblayers.conf``

using :file: would most likely look like:

:file:{BUILDDIR}/conf/layers.conf

that's getting fancy, but it is a neat feature.

in any event, i think taking advantage of at least the more obvious
roles would be useful for down the road. thoughts?

rday

#1 lore raw
Quoted 9 lines · Robert P. J. Day

one of the things that i liked about docbook was the semantic markup
that could be customized for individual tags, such that a <filename> could be rendered differently from a <command> using XSLT stylesheets and so on. at the moment, things like that are all lumped together in the .rst files by marking them up with ``blah`` double backquotes, losing all that distinction. it wouldn't be hard to put back just a *little* of those semantics by using the more obvious roles.

I like the idea.. however there is one issue/limitation.. the roles cannot be used in the context of directives, so we wouldn't be able to use them in a 'literal block' for example, and I think that's an important limitation. Can you check that? Perhaps I missed something. I agree that removing the "replaceable" semantic was a bad thing.. but that's one 'role' which is used primarily in code blocks..

Quoted 36 lines

there are two roles for marking up commands:

:command:
:program:

the distinction appears to be that a :command: is meant to represent an OS-level command to be typed literally, such as "ls" or "rm". OTOH, a :program: should represent an executable program whose name could differ based on the OS, so that you would type:

:program:sphinx-build

even if the actual name of the program on Windows was "sphinx-build.exe"; that is what i would think you would use to mark up, say, :program:devtool upgrade. currently, there doesn't appear to be any difference in the rendering, but it at least leaves open the possibility for the future, and in terms of possibly cross-referencing commands.

a third role i think would be useful is :dfn: which is used to mark
the "defining instance" of a term -- it appears to be equivalent to docbook's "firstterm" tag. this does *not* automatically generate an index entry, but i suspect it could be used for exactly that if one wanted.

finally, there is :file: for filenames, which currently is being
rendered the same as marking up with ``, but has the additional cool feature that, if you use {...} in a filename, what is inside the {} is rendered as docbook's equivalent of "replaceable", to show that it is meant to be filled in (currently rendered as bold italic). as an example of that, in the dev-manual (common tasks section), section 3.5.2, there is the expression:

  ``${BUILDDIR}/conf/bblayers.conf``
Quoted 8 lines

using :file: would most likely look like:

:file:{BUILDDIR}/conf/layers.conf

that's getting fancy, but it is a neat feature.

in any event, i think taking advantage of at least the more obvious
roles would be useful for down the road. thoughts?

yes, I think it would.. but what do you think about my previous observation ?

Quoted 5 lines

rday

#2 lore raw
Quoted 12 lines · Nicolas Dechesne
Quoted 10 lines · Robert P. J. Day

one of the things that i liked about docbook was the semantic
markup that could be customized for individual tags, such that a <filename> could be rendered differently from a <command> using XSLT stylesheets and so on. at the moment, things like that are all lumped together in the .rst files by marking them up with ``blah`` double backquotes, losing all that distinction. it wouldn't be hard to put back just a *little* of those semantics by using the more obvious roles.

Quoted 7 lines

I like the idea.. however there is one issue/limitation.. the roles cannot be used in the context of directives, so we wouldn't be able to use them in a 'literal block' for example, and I think that's an important limitation. Can you check that? Perhaps I missed something. I agree that removing the "replaceable" semantic was a bad thing.. but that's one 'role' which is used primarily in code blocks..

i'd already thought of that, and am experimenting to see what can
and can't be done with those.

rday