소스 검색

doc and test update

wangweimin 4 년 전
부모
커밋
7787f50523
7개의 변경된 파일17개의 추가작업 그리고 7개의 파일을 삭제
  1. 3 0
      .github/ISSUE_TEMPLATE/bug_report.md
  2. 1 1
      .github/workflows/release.yml
  3. 1 1
      README.md
  4. 4 0
      docs/releases/v1.1.0.rst
  5. 1 1
      pywebio/output.py
  6. 4 3
      pywebio/session/__init__.py
  7. 3 1
      test/template.py

+ 3 - 0
.github/ISSUE_TEMPLATE/bug_report.md

@@ -6,6 +6,9 @@ labels: bug
 assignees: ''
 
 ---
+注: 
+
+对于PyWebIO使用咨询或对于其他人也可能有帮助的问题,请考虑移至 [Discussions](https://github.com/wang0618/PyWebIO/discussions) 进行发帖。
 
 **BUG描述**
 描述BUG表现以及复现方式。

+ 1 - 1
.github/workflows/release.yml

@@ -44,7 +44,7 @@ jobs:
           rm -rf pywebio-assets/*
           cp -r pywebio/html/* pywebio-assets
 
-          cd pywebio-asset
+          cd pywebio-assets
           git add .
           git commit -m "Build from https://github.com/wang0618/PyWebIO/commit/$GITHUB_SHA"
           git tag $RELEASE_VERSION

+ 1 - 1
README.md

@@ -69,7 +69,7 @@ pip3 install -U https://code.aliyun.com/wang0618/pywebio/repository/archive.zip
 
 **Hello, world**
 
-这是一个使用PyWebIO计算 [BMI指数](https://en.wikipedia.org/wiki/Body_mass_index>) 的脚本:
+这是一个使用PyWebIO计算 [BMI指数](https://en.wikipedia.org/wiki/Body_mass_index) 的脚本:
 
 ```python
 from pywebio.input import input, FLOAT

+ 4 - 0
docs/releases/v1.1.0.rst

@@ -19,10 +19,14 @@ Backwards-incompatible changes
 * 移除使用 django 和 flask 框架 `start_server()` 中的 `disable_asyncio` 参数
 * 废弃 `pywebio.session.data()` ,使用 `pywebio.session.local` 作为会话本地状态存储对象
 * 整合到Web框架的应用,访问地址发生变化,参见 :ref:`Web框架整合文档 <integration_web_framework>`
+* `put_scrollable() <pywebio.output.put_scrollable>` 废弃 `max_height` 参数,使用 `height` 替代
 
 Detailed changes
 ^^^^^^^^^^^^^^^^^
+* `put_code() <pywebio.output.put_code>` 支持使用 `rows` 参数限制最大显示行数
+* `put_scrollable() <pywebio.output.put_scrollable>` 支持使用 `keep_bottom` 参数设定自动滚动到底部
 * `put_markdown() <pywebio.output.put_markdown>` 支持配置Markdown解析参数
 * 为 `put_code() <pywebio.output.put_code>`, `put_image() <pywebio.output.put_image>`, `put_link() <pywebio.output.put_link>`, `put_row() <pywebio.output.put_row>`, `put_grid() <pywebio.output.put_grid>` 中的参数添加转义
+* `output()  <pywebio.output.output>` 的 ``reset()``, ``append()``, ``insert()`` 方法接受字符串作为输出内容
 * 修复: `file_upload() <pywebio.input.file_upload>` 的 `max_size` and `max_total_size` 参数解析错误
 * 修复: py3.6自动打开浏览器失败

+ 1 - 1
pywebio/output.py

@@ -303,7 +303,7 @@ def put_text(*texts, sep=' ', inline=False, scope=Scope.Current, position=Output
 
     :param texts: 要输出的内容。类型可以为任意对象,对非字符串对象会应用 `str()` 函数作为输出值。
     :param str sep: 输出分隔符
-    :param bool inline: 将文本作为行内元素(文本行末不换行)。默认换行
+    :param bool inline: 将文本作为行内元素(连续输出的文本显示在相同的段落中)。默认每次输出的文本都作为一个独立的段落
     :param int/str scope: 内容输出的目标scope,若scope不存在,则不进行任何输出操作。
 
        可以直接指定目标Scope名,或者使用int通过索引Scope栈来确定Scope:0表示最顶层也就是ROOT Scope,-1表示当前Scope,-2表示进入当前Scope的前一个Scope,...

+ 4 - 3
pywebio/session/__init__.py

@@ -96,7 +96,7 @@ from functools import wraps
 from .base import Session
 from .coroutinebased import CoroutineBasedSession
 from .threadbased import ThreadBasedSession, ScriptModeSession
-from ..exceptions import SessionNotFoundException, SessionException
+from ..exceptions import SessionNotFoundException, SessionException, PyWebIOWarning
 from ..utils import iscoroutinefunction, isgeneratorfunction, run_as_function, to_coroutine, ObjectDictProxy
 
 # 当前进程中正在使用的会话实现的列表
@@ -376,6 +376,7 @@ def defer_call(func):
 # session-local data object
 local = ObjectDictProxy(lambda: get_current_session().save)
 
+
 def data():
     """获取当前会话的数据对象(session-local object)。
 
@@ -385,8 +386,8 @@ def data():
     global local
 
     import warnings
-    warnings.warn("Passing 'dict' as keyword argument is deprecated",
-                  DeprecationWarning, stacklevel=2)
+    warnings.warn("`pywebio.session.data()` is deprecated in v1.1 and will remove in the future version, "
+                  "use `pywebio.session.local` instead", DeprecationWarning, stacklevel=2)
     return local
 
 

+ 3 - 1
test/template.py

@@ -180,7 +180,7 @@ def basic_output():
     ], open=True)
     put_collapse('title', 'something', open=True)
 
-    put_scrollable('scrollable\n' * 20, max_height=50)
+    put_scrollable('scrollable\n' * 20, height=50, keep_bottom=True)
 
     put_markdown('### Scope')
     with use_scope('scope1'):
@@ -738,6 +738,8 @@ def save_output(browser: Chrome, filename=None, process_func=None):
     """
     raw_html = browser.find_element_by_id('markdown-body').get_attribute('innerHTML')
     html = re.sub(r'"pywebio-scope-.*?"', '', raw_html)
+    html = re.sub(r'id="pywebio-.*?"', '', html)
+    html = re.sub(r"\('pywebio-.*?'\)", '', html)
     html = re.sub(r"WebIO.pushData\(.*?\)", '', html)
     html = re.sub(r"</(.*?)>", r'</\g<1>>\n', html)  # 进行断行方便后续的diff判断
     html = html.replace('"opacity: 1;"', '').replace(' open=""', '')  # so wired