Demo¶
This is used to demonstrate various features, and also for testing.
Autodoc¶
- class piccolo_theme.snippets.Column(null: bool = False, primary_key: bool = False, unique: bool = False, index: bool = False, required: bool = False, help_text: str | None = None, choices: Type[Enum] | None = None, db_column_name: str | None = None, secret: bool = False, **kwargs)¶
All other columns inherit from
Column. Don’t use it directly.The following arguments apply to all column types:
- Parameters:
null – Whether the column is nullable.
primary_key – If set, the column is used as a primary key.
default – The column value to use if not specified by the user.
unique – If set, a unique contraint will be added to the column.
index – Whether an index is created for the column, which can improve the speed of selects, but can slow down inserts.
index_method – If index is set to
True, this specifies what type of index is created.required – This isn’t used by the database - it’s to indicate to other tools that the user must provide this value. Example uses are in serialisers for API endpoints, and form fields.
help_text – This provides some context about what the column is being used for. For example, for a
Decimalcolumn calledvalue, it could say'The units are millions of dollars'. The database doesn’t use this value, but tools such as Piccolo Admin use it to show a tooltip in the GUI.choices – An optional Enum - when specified, other tools such as Piccolo Admin will render the available options in the GUI.
db_column_name –
If specified, you can override the name used for the column in the database. The main reason for this is when using a legacy database, with a problematic column name (for example
'class', which is a reserved Python keyword). Here’s an example:class MyTable(Table): class_ = Varchar(db_column_name="class") >>> await MyTable.select(MyTable.class_) [{'id': 1, 'class': 'test'}]
This is an advanced feature which you should only need in niche situations.
secret –
If
secret=Trueis specified, it allows a user to automatically omit any fields when doing a select query, to help prevent inadvertent leakage of sensitive data.class Band(Table): name = Varchar() net_worth = Integer(secret=True) >>> await Band.select(exclude_secrets=True) [{'name': 'Pythonistas'}]
Breathe¶
We can’t demo Breathe on this version of Sphinx.
Code Blocks¶
Basic¶
def say_hello():
print("hello world!")
Emphasize¶
def say_hello():
print("hello world!")
Line numbers¶
1def say_hello():
2 print("hello world!")
Caption¶
def say_hello():
print("hello world!")
Syntax highlighting¶
An example of how syntax highlighting looks for various bits of code:
a = 1
print(a)
def hello_world():
print("hello world!")
class Greeting():
def __init__(self, message: str):
self.message = message
def greeting(self):
print(self.message)
if __name__ == '__main__':
greeting = Greeting(message="hello world")
greeting.greeting()
Tables¶
Table 1¶
Name |
Drives |
|---|---|
Alice |
True |
Bob |
True |
Curtis |
False |
Table 2¶
Header 1 |
Header 2 |
Header 3 |
|---|---|---|
body row 1 |
column 2 |
column 3 |
body row 2 |
Cells may span columns. And several paragraphs. |
|
body row 3 |
Cells may span rows. |
|
body row 4 |
||
Data definitions¶
- Python
A great programming language.
- Sphinx
A powerful documentation tool.
Lists¶
Unordered List¶
Python
Rust
JavaScript
Ordered List¶
Explicit numbers:
Python
Rust
JavaScript
Auto numbers:
Python
Rust
JavaScript
Lower-alpha:
Rust
C++
C
Upper-alpha:
reStructuredText
HTML
Markdown
Lower-roman:
reStructuredText
HTML
Markdown
Upper-roman:
reStructuredText
HTML
Markdown
Nested List¶
Languages
Python
Rust
JavaScript
Admonitions¶
Warning
This is a warning!
Error
This is an error!
Hint
This is a hint!
Note
This is a note!
A custom admonition
This is my custom admonition!