3 Inspect and Load Codes

Pheasant can read codes from a file system or Python module.

3.1 File system

Any text files are read from file system by Pheasant's extended Markdown syntax: ![file](<file name>). For example,

![file](mkdocs.yml)

writes the content of the real mkdocs.yml of this document:

site_name: Pheasant
site_url: https://pheasant.daizutabi.net/
site_description: Project documentation with MkDocs.
site_author: daizutabi

repo_url: https://github.com/daizutabi/pheasant/
edit_uri: ""

theme: readthedocs

plugins:
  - pheasant:
      bar: 10
    # - jupyter:
    #   - kernel_name:
    #       python: python3
    # - number:
    #     ignored_path: "*/about/*"

nav:
  - Home: index.md
  - User Guide:
    - Images: user-guide/images.md
    - Code: user-guide/code.md
    - Script: user-guide/script.py
  - About:
    - Release Notes: about/release-notes.md
    - License: about/license.md

markdown_extensions:
  - admonition
  - pymdownx.arithmatex
#   - attr_list

The root directory of a relative path is the directory where mkdocs.yml exists.

If the file is too long to display the whole content, you can specify the lines as the same way that Python does with the slice notation. Use < and > insted of [ and ] because [ and ] can be a part of a file name.

![file](mkdocs.yml<5:10>)
repo_url: https://github.com/daizutabi/pheasant/
edit_uri: ""

theme: readthedocs

Imported file can be numbered like figures and tables. Use this shorthand notation:

#![file](mkdocs.yml<:8>)

File 3.1 mkdocs.yml<:8>

site_name: Pheasant
site_url: https://pheasant.daizutabi.net/
site_description: Project documentation with MkDocs.
site_author: daizutabi

repo_url: https://github.com/daizutabi/pheasant/
edit_uri: ""

3.2 Python module source

Python module sources that the current Jupyter kernel can find are also inspected. Now Pheasant imported its own package pheasant, so you can read the source from this document.

You can write to inspect the whole module content:

#![python](pheasant)

Code 3.1 pheasant

__version__ = "1.2.2"

Just version number now.

A part of the module can be specified as usual.

from pheasant.core import page
#![python](page.Page)

Code 3.2 page.Page

class Page(Base):
    source: str = ""
    output: str = ""

With this functionality, you can guarantee the reproducible relation between your source code and results easily.