我有使用 sphinx 构建的静态 html 文档:
$AIRFLOW_HOME/plugins/docs/
我想在 Airflow UI 中创建一个新的菜单链接“我的文档”,这样就可以了:
class DocsView(BaseView):
@expose("/")
def my_docs(self):
return send_from_directory(os.path.abspath("plugins/docs/build/html"), 'index.html')
docs_view = DocsView(
category="My Documentation",
name="Plugins",
endpoint="my_docs"
)
在我的自定义插件类中:
class MyPlugin(AirflowPlugin):
admin_views = [docs_view]
链接成功显示在菜单栏中并且有效,但仅适用于index.html。我不使用模板,只需要可以读取所有自定义代码文档的部分。
最佳答案
我找到了解决方案。我必须在 DocsView 中添加静态 url 和文件夹路径,因为 sphinx 在 build/html 中创建其他目录:
docs_view = DocsView(
static_folder=os.path.abspath("plugins/docs/build/html"),
static_url_path="/",
category="My Documentation",
name="Plugins",
endpoint="my_docs"
)
关于python - Airflow 提供静态 html 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56461918/