Content

Note: Function Content support requires running znai in an environment with Python 3.8 or later. All the examples below are from the following example Python file: Use plugin to extract function, class or global variable content. my_var = "a variable" def my_func(p1, p2): """ text inside my *func* doc * list one * list two Parameters ---------- p1: String parameter one description p2: String parameter two description """ return 2 + 2 class Animal: """ animal top level class doc string ``` code block ``` """ def says(self): """ animal **talks** `code` """ print("hello") include-python

Function

To show the full contents of a function: This also works for global functions: To show a function's body, without signature or doc string: This also works for global functions: :include-python: python/example.py {entry: "Animal.says"} def says(self): """ animal **talks** `code` """ print("hello") :include-python: python/example.py {entry: "my_func"} def my_func(p1, p2): """ text inside my *func* doc * list one * list two Parameters ---------- p1: String parameter one description p2: String parameter two description """ return 2 + 2 :include-python: python/example.py {entry: "Animal.says", bodyOnly: true} print("hello") :include-python: python/example.py {entry: "my_func", bodyOnly: true} return 2 + 2

Title

Use the property to specify an extracted snippet title. title :include-python: python/example.py {entry: "Animal.says", bodyOnly: true, title: "extracted snippet"} print("hello")

Anchor

Use to make a code snippet linkable. Hover mouse over title to see a clickable anchor. anchorId :include-python: python/example.py { entry: "Animal.says", bodyOnly: true, title: "extracted snippet", anchorId: "my-extracted-snippet" } print("hello")

Variable

To show a variable's definition and assignment: To show only a variable's value: :include-python: python/example.py {entry: "my_var"} my_var = "a variable" :include-python: python/example.py {entry: "my_var", bodyOnly: true} "a variable"

Class

To show the full class definition: To show the contents of a class without the class declaration or doc string: :include-python: python/example.py {entry: "Animal"} class Animal: """ animal top level class doc string ``` code block ``` """ def says(self): """ animal **talks** `code` """ print("hello") :include-python: python/example.py {entry: "Animal", bodyOnly: true} def says(self): """ animal **talks** `code` """ print("hello")