docs and refactor

This commit is contained in:
Will McGugan
2023-02-14 15:22:15 +00:00
parent ea74ca7725
commit 71d0017ef9
19 changed files with 1449 additions and 123 deletions

View File

@@ -0,0 +1,60 @@
from textual.app import App, ComposeResult
from textual.widgets import MarkdownViewer
EXAMPLE_MARKDOWN = """\
# Markdown Viewer
This is an example of Textual's `MarkdownViewer` widget.
## Features
Markdown syntax and extensions are supported.
- Typography *emphasis*, **strong**, `inline code` etc.
- Headers
- Lists (bullet and ordered)
- Syntax highlighted code blocks
- Tables!
## Tables
Tables are displayed in a DataTable widget.
| Name | Type | Default | Description |
| --------------- | ------ | ------- | ---------------------------------- |
| `show_header` | `bool` | `True` | Show the table header |
| `fixed_rows` | `int` | `0` | Number of fixed rows |
| `fixed_columns` | `int` | `0` | Number of fixed columns |
| `zebra_stripes` | `bool` | `False` | Display alternating colors on rows |
| `header_height` | `int` | `1` | Height of header row |
| `show_cursor` | `bool` | `True` | Show a cell cursor |
## Code Blocks
Code blocks are syntax highlighted, with guidelines.
```python
class ListViewExample(App):
def compose(self) -> ComposeResult:
yield ListView(
ListItem(Label("One")),
ListItem(Label("Two")),
ListItem(Label("Three")),
)
yield Footer()
```
"""
class MarkdownExampleApp(App):
def compose(self) -> ComposeResult:
yield MarkdownViewer(EXAMPLE_MARKDOWN, show_toc=True)
if __name__ == "__main__":
app = MarkdownExampleApp()
app.run()