Skip to content

Python guide: include code examples using Jekyll #519

Open
@gkunz

Description

@gkunz

One objective of the Python guide is to provide executable code examples in separate Python scripts. At the same time, the code examples should also be shown in listings in the guide.

Problem: Markdown itself does not allow to include other files, i.e., such as the code examples.

Proposal: To avoid duplicating the code of the scripts in the markdown files, we can use Jekyll's include_relate primitive [1] to include the scripts in the rendered guide.

Specifically, this pattern seems to work:

```python
{% include_relative compliant01.py %}
```

[1] https://jekyllrb.com/docs/includes/#including-files-relative-to-another-file

cc @myteron @tommcd

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions