Viktors
Viktors

Reputation: 11

Get code from rst file code-blocks

What is the best and simplest way to parse *.rst file and get all code from code-blocks to execute (or compile) this code? This may be useful to test some instructions in .rst format and use them for CI purposes.

Thanks!

Upvotes: 1

Views: 1301

Answers (1)

cweiske
cweiske

Reputation: 31088

It's actually easier to put the code examples into separate files and include them into the .rst file:

This is a code block from a file:

.. include:: file.php
   :code: php

See the include directive's documentation.

Upvotes: 2

Related Questions