ソースを参照

including readme in api reference and improving styling

Rodja Trappe 4 年 前
コミット
9100e3a7a2
2 ファイル変更9 行追加3 行削除
  1. 8 2
      api_reference.py
  2. 1 1
      nicegui/elements/input.py

+ 8 - 2
api_reference.py

@@ -5,6 +5,7 @@ from contextlib import contextmanager
 from icecream import ic
 from icecream import ic
 import inspect
 import inspect
 from executing import Source
 from executing import Source
+from nicegui.elements.element import Element
 import sys
 import sys
 import docutils.core
 import docutils.core
 
 
@@ -27,12 +28,17 @@ def example():
         code = '\n'.join(code)
         code = '\n'.join(code)
         ui.markdown(code)
         ui.markdown(code)
 
 
-def describe(element, headline):
+def describe(element: Element):
     doc = element.__init__.__doc__
     doc = element.__init__.__doc__
     html = docutils.core.publish_parts(doc, writer_name='html')['html_body']
     html = docutils.core.publish_parts(doc, writer_name='html')['html_body']
+    html = html.replace('<p>', '<h3>', 1)
+    html = html.replace('</p>', '</h3>', 1)
     ui.html(html)
     ui.html(html)
 
 
-describe(ui.input, 'Text Input')
+with open('README.md', 'r') as file:
+    ui.markdown(file.read())
+
+describe(ui.input)
 with example():
 with example():
     ui.input(label='Text', on_change=lambda e: result.set_text(e.value))
     ui.input(label='Text', on_change=lambda e: result.set_text(e.value))
     ui.number(label='Number', format='%.2f', on_change=lambda e: result.set_text(e.value))
     ui.number(label='Number', format='%.2f', on_change=lambda e: result.set_text(e.value))

+ 1 - 1
nicegui/elements/input.py

@@ -11,7 +11,7 @@ class Input(StringElement):
                  value: str = '',
                  value: str = '',
                  design: str = '',
                  design: str = '',
                  on_change: Callable = None):
                  on_change: Callable = None):
-        """Text Input Element.
+        """Text Input Element
 
 
         :param str label: display name for the text input
         :param str label: display name for the text input
         :param str placeholder: text to show if no value is entered
         :param str placeholder: text to show if no value is entered