Was this page helpful?
Caution
You're viewing documentation for an unstable version of ScyllaDB Sphinx Theme. Switch to the latest stable version.
Code block directives are for displaying code. By default the code is copyable and includes a copy icon. To keep code snippets neat, separate the display from the command. This keeps the command copyable without having the screen return inside the command.
For example using the rst code block before a restructuredText example:
.. code-block:: rst
when used with the .. tip:: here's a tip
as shown above, renders as:
.. tip:: here's a tip
The code block directive can be changed to a language which is supported by restructuredText. For example, the following code-block is cql. If you add the following code block directive, to the code sample below:
.. code-block:: cql
create_keyspace_statement: CREATE KEYSPACE [ IF NOT EXISTS ] `keyspace_name` WITH `options`
You see that there is syntax highlighting.
The key item to remember is that the entire code block needs three spaces before any line. The code will automatically be highlighted.
You can create code-blocks in any of the following languages. Using none
is also acceptable. If you use none, there is no syntax highlighting.
create_keyspace_statement: CREATE KEYSPACE [ IF NOT EXISTS ] `keyspace_name` WITH `options`
If you are including a large example (an entire file) as a code-block, refer to Literal Include.
To show the line number, add the option :linenos: to the code-block directive.
For example:
.. code-block:: rst
:linenos:
Line 1
Line 2
Renders:
1Line 1
2Line 2
Add the class hide-copy-button
to the code-block
directive to hide the copy button.
For example:
.. code-block:: rst
:class: hide-copy-button
.. tip:: here's a tip
Renders:
.. tip:: here's a tip
Was this page helpful?