[OpenStack-docs] italicized python cmds, literal blocks

Russell Sim russell.sim at gmail.com
Tue Jun 30 01:09:19 UTC 2015


I believe that :: is defaulting to python console (pycon) highlighting.
This would make sense, as python doc tests were all the rage back when
sphinx was created.

If you are using the .. code-block:: you can get a full list of supported
lexers using pygmentize -L  and there is a highlighting test here
http://pygments.org/demo/

It looks like you can set the default highlighting to use for all :: blocks
using the .. highlight: directive http://sphinx-doc.org/markup/code.html

so if you are documenting all console sessions in a file, you should add
this to the top of your file.

.. highlight:: console

Then any subsequent :: blocks will use console highlighting by default.

If you spot any problems, I can have a crack at fixing the problem but your
best bet is to submit a bug here
https://bitbucket.org/birkenfeld/pygments-main/issues?status=new&status=open
most of the lexers rely heavily on regular expressions so there are likely
some edge cases. One is in the python console mode if you are missing a
space after the >>> prompt it won't highlight correctly.

Shell (console) highlighting
http://pygments.org/demo/2034953/

Python (pycon) highlighting
http://pygments.org/demo/2034997/

On 30 June 2015 at 08:21, Anne Gentle <annegentle at justwriteclick.com> wrote:

>
>
> On Mon, Jun 29, 2015 at 3:38 PM, Matt Kassawara <mkassawara at gmail.com>
> wrote:
>
>> I just use "Blah blah blah::" in the networking guide and it seems to
>> handle both config files and CLI.
>>
>>
> Interesting data point Matt, and observation Karen.
>
> So, what she's pointing out can be seen by looking at
> http://docs.openstack.org/networking-guide/misc_libvirt.html
> and then looking at the RST source:
>
> https://raw.githubusercontent.com/openstack/openstack-manuals/master/doc/networking-guide/source/misc_libvirt.rst
>
> She's asking, why does # virsh net list not have italics but #virsh net
> net-destroy default is not italicized? Both use the :: convention in the
> prior paragraph. That's where we may need another convention to use
> ..code-block:: console throughout books like the Networking Guide.
>
> What do you think, change conventions to use the ..code-block:: console
> for those guides?
> Anne
>
>
>> On Mon, Jun 29, 2015 at 2:33 PM, Gauvain Pocentek <
>> gauvain.pocentek at objectif-libre.com> wrote:
>>
>>> Le 2015-06-29 22:12, Karen Bradshaw a écrit :
>>>
>>>> Hi.  I have been looking into the use of :: vs .. code-block::
>>>> in the newly converted RST guides.  I have found some inconsistencies.
>>>> I found that using a root-privileged python executable with the pound
>>>> sign, gets
>>>>
>>>> formatted like a python comment (italicized).
>>>> If there is output shown after the command
>>>> then the cmd and output are not italicized but treated as literal
>>>> text; the single colon directive is used in this case.
>>>> Using the dollar prompt, everything works as expected (not italicized).
>>>> We use the literal block directive, double colon, throughout the RST
>>>> guides.
>>>> One way I found to get around this is to always use the dollar prompt.
>>>> Another way is .. code-block::java.  It is a hack, but it generates the
>>>> correct
>>>> output for the pound sign <python cmd>.
>>>> May be someone can shed some light on this problem.
>>>>
>>>
>>> You probably want to use '.. code-block:: console' for interactive shell
>>> sessions (a prompt and a command followed by its output). This will show a
>>> different color for the prompt and for shell builtin commands.
>>>
>>> If I'm not mistaken :: always uses python syntax highlighting (so italic
>>> after a # sign is normal behavior), unless you specified another lexer to
>>> use in your document.
>>>
>>> Gauvain Pocentek
>>>
>>> Objectif Libre - Infrastructure et Formations Linux
>>> http://www.objectif-libre.com
>>>
>>> _______________________________________________
>>> OpenStack-docs mailing list
>>> OpenStack-docs at lists.openstack.org
>>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-docs
>>>
>>
>>
>> _______________________________________________
>> OpenStack-docs mailing list
>> OpenStack-docs at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-docs
>>
>>
>
>
> --
> Anne Gentle
> Rackspace
> Principal Engineer
> www.justwriteclick.com
>
> _______________________________________________
> OpenStack-docs mailing list
> OpenStack-docs at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-docs
>
>


-- 
Cheers,
Russell Sim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-docs/attachments/20150630/0785e401/attachment.html>


More information about the OpenStack-docs mailing list