Scylla University Live | Free Virtual Training Event
Learn more
Scylla Documentation Logo Documentation
  • Server
    • Scylla Open Source
    • Scylla Enterprise
    • Scylla Alternator
  • Cloud
    • Scylla Cloud
    • Scylla Cloud Docs
  • Tools
    • Scylla Manager
    • Scylla Monitoring Stack
    • Scylla Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
Download
Menu

Caution

You're viewing documentation for an unstable version of Scylla Sphinx Theme. Switch to the latest stable version.

Scylla Sphinx Theme Examples Code blocks

Code blocks¶

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.

Basic usage¶

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.

Hide copy button¶

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
PREVIOUS
Collapse
NEXT
Glossary
  • master
    • 1.2
    • 1.1
    • 1.0
  • Getting started
    • Toolchain
    • Installation
  • Configuration
    • Template options
    • Page options
    • Multiversion options
    • Markdown support
    • Redirections support
    • Troubleshooting
  • Commands
  • Deployment
    • Production deployment
    • Pull requests previews
  • Examples
    • Admonitions
    • Collapse
    • Code blocks
    • Glossary
    • Headings
    • Hero box
    • Includes
    • Images
    • Links
    • Lists
    • Panel box
    • Substitutions
    • Tables
    • Tabs
    • Text
    • TOC
    • Topic box
    • Versions
  • Upgrade guides
    • Migrating from 1.1 to 1.2
    • Migrating from 1.0 to 1.1
    • Migrating from 0.x to 1.0
    • Changelog
  • Contribute
    • Contribute to the documentation
    • Contribute to the theme
    • Source Code
  • Create an issue
  • Edit this page

On this page

  • Code blocks
    • Basic usage
    • Hide copy button
Logo
Docs Contact Us About Us
Mail List Icon Slack Icon
© 2022, ScyllaDB. All rights reserved.
Last updated on 03 May 2022.
Powered by Sphinx 4.5.0 & ScyllaDB Theme 1.2.1