Fix roll docs page by resolving markdown from repo root.

The /strategy/roll/docs link looked under lib/strategy/ while 顺势加仓滚仓说明.md lives at the repository root.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-15 22:29:14 +08:00
parent a21b962bf1
commit 0939274113
+15 -2
View File
@@ -129,8 +129,8 @@ def register_strategy_trading(app: Flask, cfg: dict[str, Any]) -> None:
@_lr
@app.route("/strategy/roll/docs")
def strategy_roll_docs():
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "顺势加仓滚仓说明.md")
if not os.path.isfile(path):
path = _resolve_roll_doc_path()
if not path:
flash("滚仓说明文档不存在")
return redirect(url_for("strategy_trading_page"))
with open(path, encoding="utf-8") as f:
@@ -142,6 +142,19 @@ def register_strategy_trading(app: Flask, cfg: dict[str, Any]) -> None:
)
def _resolve_roll_doc_path() -> str | None:
"""滚仓说明 md:优先包内,否则仓库根目录(顺势加仓滚仓说明.md)."""
here = os.path.dirname(os.path.abspath(__file__))
name = "顺势加仓滚仓说明.md"
for path in (
os.path.join(here, name),
os.path.normpath(os.path.join(here, "..", "..", name)),
):
if os.path.isfile(path):
return path
return None
def _roll_doc_markdown_to_html(text: str) -> str:
"""轻量 Markdown → HTML(仅供滚仓说明页)."""
lines = text.splitlines()