[Fix] In-app documentation (#6185)

* In-app documentation correction

* In app images fix proposal
This commit is contained in:
Charles-Henri Decultot 2018-10-05 07:59:37 +02:00 committed by Rushabh Mehta
parent 08edf6e208
commit 09cdb2f39b
2 changed files with 16 additions and 7 deletions

View file

@ -84,7 +84,16 @@ def make_asset_dirs(make_copy=False, restore=False):
symlinks = []
symlinks.append([os.path.join(app_base_path, 'public'), os.path.join(assets_path, app_name)])
symlinks.append([os.path.join(app_base_path, 'docs'), os.path.join(assets_path, app_name + '_docs')])
app_doc_path = None
if os.path.isdir(os.path.join(app_base_path, 'docs')):
app_doc_path = os.path.join(app_base_path, 'docs')
elif os.path.isdir(os.path.join(app_base_path, 'www', 'docs')):
app_doc_path = os.path.join(app_base_path, 'www', 'docs')
if app_doc_path:
symlinks.append([app_doc_path, os.path.join(assets_path, app_name + '_docs')])
for source, target in symlinks:
source = os.path.abspath(source)

View file

@ -166,8 +166,8 @@ class HelpDatabase(object):
docs_app=docs_app, web_folder=web_folder)
if os.path.exists(docs_folder):
app_name = getattr(frappe.get_module(app), '__title__', None) or app.title()
doc_contents += '<li><a data-path="/{docs_app}/index">{app_name}</a></li>'.format(
docs_app=docs_app, app_name=app_name)
doc_contents += '<li><a data-path="/{app}/index">{app_name}</a></li>'.format(
app=app, app_name=app_name)
for basepath, folders, files in os.walk(docs_folder):
files = self.reorder_files(files)
@ -177,14 +177,14 @@ class HelpDatabase(object):
with io.open(fpath, 'r', encoding = 'utf-8') as f:
try:
content = frappe.render_template(f.read(),
{'docs_base_url': '/assets/{app}_docs'.format(app=app)})
{'docs_base_url': '/assets/{docs_app}_docs'.format(docs_app=docs_app)})
relpath = self.get_out_path(fpath)
relpath = relpath.replace("user", app)
content = frappe.utils.md_to_html(content)
title = self.make_title(basepath, fname, content)
intro = self.make_intro(content)
content = self.make_content(content, fpath, relpath, app)
content = self.make_content(content, fpath, relpath, app, docs_app)
self.db.sql('''insert into help(path, content, title, intro, full_path)
values (%s, %s, %s, %s, %s)''', (relpath, content, title, intro, fpath))
except jinja2.exceptions.TemplateSyntaxError:
@ -212,7 +212,7 @@ class HelpDatabase(object):
intro = "Help Video: " + intro
return intro
def make_content(self, html, path, relpath, app_name):
def make_content(self, html, path, relpath, app_name, doc_app):
if '<h1>' in html:
html = html.split('</h1>', 1)[1]
@ -222,7 +222,7 @@ class HelpDatabase(object):
soup = BeautifulSoup(html, 'html.parser')
self.fix_links(soup, app_name)
self.fix_images(soup, app_name)
self.fix_images(soup, doc_app)
parent = self.get_parent(relpath)
if parent: