restructured_text_documentation.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.restructured_text)
  4. def main_demo() -> None:
  5. ui.restructured_text('This is **reStructuredText**.')
  6. @doc.demo('reStructuredText with indentation', '''
  7. You can indent reStructuredText elements to create a hierarchy.
  8. Common indentation is automatically stripped from the beginning of each line to preserve the relative indentation,
  9. so you can indent multiline strings.
  10. ''')
  11. def rst_with_indentation():
  12. ui.restructured_text('''
  13. This is an example of a reStructuredText paragraph with several indentation levels.
  14. You can use multiple levels of indentation to structure your content.
  15. Each level of indentation represents a different level of hierarchy.
  16. - Level 1
  17. - Level 2
  18. - Level 3
  19. - Level 4
  20. - Level 5
  21. ''')
  22. @doc.demo('reStructuredText with code blocks', '''
  23. You can use code blocks to show code examples.
  24. If you specify the language, the code will be syntax-highlighted.
  25. See [this link](https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/WritingReST/Reference/Code/Codeblocks.html#writing-rest-codeblocks-available-lexers) for a list of supported languages.
  26. ''')
  27. def rst_with_code_blocks():
  28. ui.restructured_text('''
  29. .. code-block:: python3
  30. from nicegui import ui
  31. ui.label('Hello World!')
  32. ui.run()
  33. ''')
  34. @doc.demo('reStructuredText with tables', '''
  35. See the [sphinx documentation](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#tables)
  36. for more information about reStructuredText tables.
  37. ''')
  38. def rst_tables():
  39. ui.restructured_text('''
  40. +-------+-------+---------+--------+
  41. | A | B | A and B | A or B |
  42. +=======+=======+=========+========+
  43. | False | False | False | False |
  44. +-------+-------+---------+--------+
  45. | True | False | False | True |
  46. +-------+-------+---------+--------+
  47. | False | True | False | True |
  48. +-------+-------+---------+--------+
  49. | True | True | True | True |
  50. +-------+-------+---------+--------+
  51. ''')
  52. doc.reference(ui.restructured_text)