From 28b5589c7268b9b6ce9197ce62358e7e61dec4bd Mon Sep 17 00:00:00 2001 From: Kenneth Sequeira Date: Fri, 19 Oct 2018 03:22:17 +0530 Subject: [PATCH 1/7] Docs setup code same as v11 Currently, in v10, the docs still point to ERPNext develop branch, before it being moved to erpnext.org app. Co-authored-by: Shreya Shah > --- frappe/hooks.py | 2 ++ frappe/utils/help.py | 26 ++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/frappe/hooks.py b/frappe/hooks.py index 4a76ee075b..0d378326a2 100755 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -15,6 +15,8 @@ develop_version = '10.x.x-develop' app_email = "info@frappe.io" +docs_app = "frappe_io" + before_install = "frappe.utils.install.before_install" after_install = "frappe.utils.install.after_install" diff --git a/frappe/utils/help.py b/frappe/utils/help.py index c76e977dd8..fc7642444b 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -125,8 +125,15 @@ class HelpDatabase(object): apps = os.listdir('../apps') if self.global_help_setup else frappe.get_installed_apps() for app in apps: - docs_folder = '../apps/{app}/{app}/docs/user'.format(app=app) - self.out_base_path = '../apps/{app}/{app}/docs'.format(app=app) + # Expect handling of cloning docs apps in bench + docs_app = frappe.get_hooks('docs_app', app, app)[0] + + web_folder = 'www/' if docs_app != app else '' + + docs_folder = '../apps/{docs_app}/{docs_app}/{web_folder}docs/user'.format( + docs_app=docs_app, web_folder=web_folder) + self.out_base_path = '../apps/{docs_app}/{docs_app}/{web_folder}docs'.format( + 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 += '
  • {app_name}
  • '.format( @@ -140,14 +147,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 = markdown(content) title = self.make_title(basepath, fname, content) intro = self.make_intro(content) - content = self.make_content(content, fpath, relpath) + 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: @@ -301,3 +308,14 @@ class HelpDatabase(object): if pos: files[0], files[pos] = files[pos], files[0] return files + +def setup_apps_for_docs(app): + docs_app = frappe.get_hooks('docs_app', app, app)[0] + + if docs_app and not os.path.exists(frappe.get_app_path(app)): + print("Getting {docs_app} required by {app}".format(docs_app=docs_app, app=app)) + subprocess.check_output(['bench', 'get-app', docs_app], cwd = '..') + else: + if docs_app: + print("{docs_app} required by {app} already present".format(docs_app=docs_app, app=app)) + From 1f8c8568edbd0eb181474690ea34e4499eba088c Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Fri, 19 Oct 2018 11:44:51 +0530 Subject: [PATCH 2/7] Update help.py --- frappe/utils/help.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frappe/utils/help.py b/frappe/utils/help.py index fc7642444b..20789bd22c 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -182,7 +182,7 @@ class HelpDatabase(object): intro = "Help Video: " + intro return intro - def make_content(self, html, path, relpath): + def make_content(self, html, path, relpath, app_name, doc_app): if '

    ' in html: html = html.split('

    ', 1)[1] @@ -190,13 +190,12 @@ class HelpDatabase(object): html = html.replace('{next}', '') target = path.split('/', 3)[-1] - app_name = path.split('/', 3)[2] html += get_improve_page_html(app_name, target) 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: From 0473ea9c6b48e8d0e35311114217f60fc6c1f0a2 Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Fri, 19 Oct 2018 14:09:49 +0530 Subject: [PATCH 3/7] Update help.py --- frappe/utils/help.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/frappe/utils/help.py b/frappe/utils/help.py index 20789bd22c..b3f7059e75 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -307,14 +307,3 @@ class HelpDatabase(object): if pos: files[0], files[pos] = files[pos], files[0] return files - -def setup_apps_for_docs(app): - docs_app = frappe.get_hooks('docs_app', app, app)[0] - - if docs_app and not os.path.exists(frappe.get_app_path(app)): - print("Getting {docs_app} required by {app}".format(docs_app=docs_app, app=app)) - subprocess.check_output(['bench', 'get-app', docs_app], cwd = '..') - else: - if docs_app: - print("{docs_app} required by {app} already present".format(docs_app=docs_app, app=app)) - From 8e0410bdb0518c08392053e3c6bd5cdba94f9d26 Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Fri, 19 Oct 2018 14:21:36 +0530 Subject: [PATCH 4/7] Update help.py --- frappe/utils/help.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/frappe/utils/help.py b/frappe/utils/help.py index b3f7059e75..b9b1c3adf3 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -128,12 +128,8 @@ class HelpDatabase(object): # Expect handling of cloning docs apps in bench docs_app = frappe.get_hooks('docs_app', app, app)[0] - web_folder = 'www/' if docs_app != app else '' - - docs_folder = '../apps/{docs_app}/{docs_app}/{web_folder}docs/user'.format( - docs_app=docs_app, web_folder=web_folder) - self.out_base_path = '../apps/{docs_app}/{docs_app}/{web_folder}docs'.format( - docs_app=docs_app, web_folder=web_folder) + docs_folder = '../apps/{app}/{app}/docs/user'.format(app=app) + self.out_base_path = '../apps/{app}/{app}/docs'.format(app=app) if os.path.exists(docs_folder): app_name = getattr(frappe.get_module(app), '__title__', None) or app.title() doc_contents += '
  • {app_name}
  • '.format( @@ -147,7 +143,7 @@ class HelpDatabase(object): with io.open(fpath, 'r', encoding = 'utf-8') as f: try: content = frappe.render_template(f.read(), - {'docs_base_url': '/assets/{docs_app}_docs'.format(docs_app=docs_app)}) + {'docs_base_url': '/assets/{app}_docs'.format(app=app)}) relpath = self.get_out_path(fpath) relpath = relpath.replace("user", app) From f31e7ac8a35020cfb5e01495150cc373dbbfe73a Mon Sep 17 00:00:00 2001 From: Kenneth Sequeira Date: Fri, 19 Oct 2018 14:26:10 +0530 Subject: [PATCH 5/7] added source link for frappe docs --- frappe/config/docs.py | 2 +- frappe/utils/help.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/config/docs.py b/frappe/config/docs.py index 4d3178e3fd..eafaeeb19e 100644 --- a/frappe/config/docs.py +++ b/frappe/config/docs.py @@ -2,5 +2,5 @@ from __future__ import unicode_literals -source_link = "https://github.com/frappe/frappe" +source_link = "https://github.com/frappe/frappe_io" docs_base_url = "/docs" diff --git a/frappe/utils/help.py b/frappe/utils/help.py index b9b1c3adf3..78c9748701 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -38,7 +38,7 @@ def get_help_content(path): def get_improve_page_html(app_name, target): docs_config = frappe.get_module(app_name + ".config.docs") source_link = docs_config.source_link - branch = getattr(docs_config, "branch", "develop") + branch = getattr(docs_config, "branch", "master") html = '''
    @@ -186,6 +186,10 @@ class HelpDatabase(object): html = html.replace('{next}', '') target = path.split('/', 3)[-1] + + if app_name != doc_app: + target = target.replace(app_name, doc_app + '/www') + app_name = path.split('/', 3)[2] html += get_improve_page_html(app_name, target) soup = BeautifulSoup(html, 'html.parser') From 1e0880493ca47bace659511937e35a8a7b53b2d9 Mon Sep 17 00:00:00 2001 From: Kenneth Sequeira Date: Fri, 19 Oct 2018 14:33:30 +0530 Subject: [PATCH 6/7] remove rogue tab space --- frappe/utils/help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/utils/help.py b/frappe/utils/help.py index 78c9748701..07103c3f21 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -188,7 +188,7 @@ class HelpDatabase(object): target = path.split('/', 3)[-1] if app_name != doc_app: - target = target.replace(app_name, doc_app + '/www') + target = target.replace(app_name, doc_app + '/www') app_name = path.split('/', 3)[2] html += get_improve_page_html(app_name, target) From 026bd0d2bcf56b0db09700f56b8806a1e9040695 Mon Sep 17 00:00:00 2001 From: Kenneth Sequeira Date: Fri, 19 Oct 2018 14:42:56 +0530 Subject: [PATCH 7/7] fixed image link --- frappe/utils/help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/utils/help.py b/frappe/utils/help.py index 07103c3f21..352923bbf3 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -195,7 +195,7 @@ class HelpDatabase(object): soup = BeautifulSoup(html, 'html.parser') self.fix_links(soup, app_name) - self.fix_images(soup, doc_app) + self.fix_images(soup, app_name) parent = self.get_parent(relpath) if parent: