Browse Source

fixed indentation

Rodja Trappe 2 years ago
parent
commit
b15fc8511b
2 changed files with 5 additions and 3 deletions
  1. 3 2
      website/example.py
  2. 2 1
      website/reference.py

+ 3 - 2
website/example.py

@@ -34,9 +34,10 @@ class example:
 
             with ui.row().classes('items-stretch max-w-screen-lg'):
                 code = inspect.getsource(f).splitlines()
-                while not code[0].startswith(' ' * 8):
+                indentation = len(code[0].split('@example')[0]) + 4
+                while not code[0].startswith(' ' * indentation):
                     del code[0]
-                code = [l[8:] for l in code]
+                code = [l[indentation:] for l in code]
                 while code[0].startswith('global '):
                     del code[0]
                 code.insert(0, '```python')

+ 2 - 1
website/reference.py

@@ -703,10 +703,11 @@ It also enables you to identify sessions using a [session middleware](https://ww
             from collections import Counter
             from datetime import datetime
 
-            from nicegui import app
             from starlette.middleware.sessions import SessionMiddleware
             from starlette.requests import Request
 
+            from nicegui import app
+
             app.add_middleware(SessionMiddleware, secret_key='some_random_string')
 
             counter = Counter()