def details_docs(entity_name, path=None): channel_request = request.args.get("channel", default=None, type=str) extra_fields = [ "default-release.revision.metadata-yaml", ] package = get_package( entity_name, channel_request, FIELDS.copy() + extra_fields ) if not package["store_front"]["docs_topic"]: return render_template( "details/empty-docs.html", package=package, channel_requested=channel_request, ) docs_url_prefix = f"/{package['name']}/docs" docs = DocParser( api=discourse_api, index_topic_id=package["store_front"]["docs_topic"], url_prefix=docs_url_prefix, ) docs.parse() if path: try: topic_id = docs.resolve_path(path)[0] except PathNotFoundError: abort(404) topic = docs.api.get_topic(topic_id) else: topic = docs.index_topic document = docs.parse_topic(topic) context = { "package": package, "navigation": docs.navigation, "body_html": document["body_html"], "last_update": document["updated"], "forum_url": docs.api.base_url, "topic_path": document["topic_path"], "channel_requested": channel_request, } return render_template("details/docs.html", **context)
def details_docs(entity_name, slug=None): package = app.store_api.get_item_details(entity_name, fields=FIELDS) package = logic.add_store_front_data(package) docs_url_prefix = f"/{package['name']}/docs" # Fake package discourse topic package["docs_topic"] = 3568 docs = DocParser( api=discourse_api, index_topic_id=package["docs_topic"], url_prefix=docs_url_prefix, ) docs.parse() body_html = docs.index_document["body_html"] topic_path = docs.index_document["topic_path"] if slug: topic_id = docs.resolve_path(slug) # topic = docs.api.get_topic(topic_id) # body_html = docs.parse_topic(topic) slug_docs = DocParser( api=discourse_api, index_topic_id=topic_id, url_prefix=docs_url_prefix, ) slug_docs.parse() body_html = slug_docs.index_document["body_html"] topic_path = slug_docs.index_document["topic_path"] context = { "package": package, "navigation": docs.navigation, "body_html": body_html, "last_update": docs.index_document["updated"], "forum_url": docs.api.base_url, "topic_path": topic_path, } return render_template("details/docs.html", **context)