diff --git a/docs/lite/api/source_en/conf.py b/docs/lite/api/source_en/conf.py index 3129348fed1a3a4d580f20bd2de693ff24cbd61e..70fb3db7910271890b61de8db785628c0a87223f 100644 --- a/docs/lite/api/source_en/conf.py +++ b/docs/lite/api/source_en/conf.py @@ -210,7 +210,7 @@ exhale_args = { EXCLUDE_PATTERNS = *schema* *third_party* HIDE_UNDOC_CLASSES = YES HIDE_UNDOC_MEMBERS = YES - EXCLUDE_SYMBOLS = operator* GVAR* + EXCLUDE_SYMBOLS = GVAR* WARNINGS = NO ENABLE_SECTIONS = DISPLAY_COMPOUND WARN_IF_UNDOCUMENTED = NO diff --git a/docs/lite/api/source_zh_cn/conf.py b/docs/lite/api/source_zh_cn/conf.py index 57ffe8f2c28ac4766e2d1f4ee27001f3582e1ea5..7078d27709a0810a3cddd7e3a70f509ab4991081 100644 --- a/docs/lite/api/source_zh_cn/conf.py +++ b/docs/lite/api/source_zh_cn/conf.py @@ -334,7 +334,7 @@ exhale_args = { EXCLUDE_PATTERNS = *schema* *third_party* HIDE_UNDOC_CLASSES = YES HIDE_UNDOC_MEMBERS = YES - EXCLUDE_SYMBOLS = operator* GVAR* + EXCLUDE_SYMBOLS = GVAR* WARNINGS = NO ENABLE_SECTIONS = DISPLAY_COMPOUND WARN_IF_UNDOCUMENTED = NO diff --git a/docs/mindspore/_ext/myautosummary.py b/docs/mindspore/_ext/myautosummary.py index 2c9027f05dac07e34cd98dfe7221d1dbbbf983e4..53fc89cbe241d4f72ad93949f47deb4641261d68 100644 --- a/docs/mindspore/_ext/myautosummary.py +++ b/docs/mindspore/_ext/myautosummary.py @@ -432,8 +432,8 @@ class MsCnAutoSummary(Autosummary): env_warn = self.default_doc_fourth return env_warn.rstrip() - def get_summary_re(self, display_name: str): - return re.compile(rf'\.\. \w+:\w+::\s+{display_name}.*?\n\n\s+(.*?)[。\n]') + # def get_summary_re(self, display_name: str): + # return re.compile(rf'\.\. \w+:\w+::\s+{display_name}.*?\n\n\s+((?:.|\n|)+?)\n\n') def run(self) -> List[Node]: self.bridge = DocumenterBridge(self.env, self.state.document.reporter, @@ -491,32 +491,37 @@ class MsCnAutoSummary(Autosummary): file_path = os.path.join(doc_path, dir_name, display_name+'.rst') spec_path = os.path.join('api_python', dir_name, display_name) if os.path.exists(file_path) and spec_path not in generated_files: - summary_re_tag = re.compile(rf'\.\. \w+:\w+::\s+{display_name}.*?\n\s+:.*?:\n\n\s+(.*?)[。\n]') - summary_re_line = re.compile(rf'\.\. \w+:\w+::\s+{display_name}(?:.|\n|)+?\n\n\s+(.*?)[。\n]') - summary_re = self.get_summary_re(display_name) + summary_re_tag = re.compile( + rf'\.\. \w+:\w+::\s+{display_name}.*?\n\s+:.*?:\n\n\s+((?:.|\n|)+?)(\n\n|。)') + summary_re_wrap = re.compile(rf'\.\. \w+:\w+::\s+{display_name}(?:.|\n|)+?\n\n\s+((?:.|\n|)+?)(\n\n|。)') + summary_re = re.compile(rf'\.\. \w+:\w+::\s+{display_name}.*?\n\n\s+((?:.|\n|)+?)(\n\n|。)') content = '' with open(file_path, 'r', encoding='utf-8') as f: content = f.read() if content: + content = re.sub('\n[ ]+\n', '\n\n', content) summary_str = summary_re.findall(content) summary_str_tag = summary_re_tag.findall(content) - summary_str_line = summary_re_line.findall(content) + summary_str_wrap = summary_re_wrap.findall(content) if '.ops.' in display_name and '更多详情请查看:' in content.split('\n')[-2]: summary_str = content.split('\n')[-2].strip() elif '.mint.' in display_name and '更多详情请查看:' in content.split('\n')[-2]: summary_str = content.split('\n')[-2].strip() - elif summary_str: - if re.findall("[::,,。.;;]", summary_str[0][-1]): - logger.warning(f"{display_name}接口的概述格式需调整") - summary_str = summary_str[0] + '。' elif summary_str_tag: - if re.findall("[::,,。.;;]", summary_str_tag[0][-1]): + if re.findall("[::,,。.;;]", summary_str_tag[0][0][-1]): + logger.warning(f"{display_name}接口的概述格式需调整") + summary_str = re.sub('\n[ ]+', '', summary_str_tag[0][0]) + '。' + logger.warning(f'tag {display_name}概述为 {summary_str}') + elif summary_str: + if re.findall("[::,,。.;;]", summary_str[0][0][-1]): logger.warning(f"{display_name}接口的概述格式需调整") - summary_str = summary_str_tag[0] + '。' - elif summary_str_line: - if re.findall("[::,,。.;;]", summary_str_line[0][-1]): + summary_str = re.sub('\n[ ]+', '', summary_str[0][0]) + '。' + logger.warning(f'{display_name}概述为 {summary_str}') + elif summary_str_wrap: + if re.findall("[::,,。.;;]", summary_str_wrap[0][0][-1]): logger.warning(f"{display_name}接口的概述格式需调整") - summary_str = summary_str_line[0] + '。' + summary_str = re.sub('\n[ ]+', '', summary_str_wrap[0][0]) + '。' + logger.warning(f'wrap {display_name}概述为 {summary_str}') else: summary_str = '' if not self.table_head: diff --git a/tools/generate_html/replace_html_menu.py b/tools/generate_html/replace_html_menu.py index 01cde4439e33323820e672e7329ed67ce019ff56..0a8fed2545302c38800feb2010efc447fe0c88ac 100644 --- a/tools/generate_html/replace_html_menu.py +++ b/tools/generate_html/replace_html_menu.py @@ -316,14 +316,10 @@ def replace_html_menu(html_path, hm_ds_path): // let the scorer override scores with a custom scoring function""" - old_searchtools_content1 = """docContent = htmlElement.find('[role=main]')[0];""" - new_searchtools_content1 = """htmlElement.find('[role=main]').find('[itemprop=articleBody]').find('style').remove(); - docContent = htmlElement.find('[role=main]')[0];""" with open(searchtools_path, 'r+', encoding='utf-8') as f: searchtools_content = f.read() new_content = searchtools_content.replace(old_searchtools_content, new_searchtools_content) new_content = new_content.replace('linkUrl +', 'requestUrl +') - new_content = new_content.replace(old_searchtools_content1, new_searchtools_content1) if new_content != searchtools_content: f.seek(0) f.truncate() diff --git a/tools/generate_html/run.py b/tools/generate_html/run.py index b6cad9ff4dc7649f28170ac533ac358e397c5bd4..1a47d2b123e2beeacca33e7f5c82409de22a13aa 100644 --- a/tools/generate_html/run.py +++ b/tools/generate_html/run.py @@ -113,12 +113,12 @@ def main(version, user, pd, WGETDIR, release_url, generate_list): # 读取json文件数据 if version == "daily": flag_dev = 1 - with open(os.path.join(os.path.dirname(__file__), "daily.json"), 'r+', encoding='utf-8') as f: - data = json.load(f) + with open(os.path.join(os.path.dirname(__file__), "daily.json"), 'r+', encoding='utf-8') as g: + data = json.load(g) else: flag_dev = 0 - with open(os.path.join(os.path.dirname(__file__), "version.json"), 'r+', encoding='utf-8') as f: - data = json.load(f) + with open(os.path.join(os.path.dirname(__file__), "version.json"), 'r+', encoding='utf-8') as g: + data = json.load(g) with open(os.path.join(os.path.dirname(__file__), "base_version.json"), 'r+', encoding='utf-8') as g: data_b = json.load(g) @@ -665,11 +665,15 @@ if __name__ == "__main__": if os.path.exists(os.path.join(output_path, f_name)): os.remove(os.path.join(output_path, f_name)) shutil.copy(os.path.join(theme_path, f_name), os.path.join(output_path, f_name)) + old_searchtools_content = """docContent = htmlElement.find('[role=main]')[0];""" + new_searchtools_content = """htmlElement.find('[role=main]').find('[itemprop=articleBody]').find('style').remove(); + docContent = htmlElement.find('[role=main]')[0];""" # pylint: disable=W0621 for lg in ['en', 'zh-CN']: # pylint: disable=W0621 for out_name in theme_list: try: + static_path_searchtools = glob.glob(f"{output_path}/{out_name}/{lg}/*/_static/searchtools.js")[0] static_path_css = glob.glob(f"{output_path}/{out_name}/{lg}/*/_static/css/theme.css")[0] static_path_js = glob.glob(f"{output_path}/{out_name}/{lg}/*/_static/js/theme.js")[0] static_path_jquery = glob.glob(f"{output_path}/{out_name}/{lg}/*/_static/jquery.js")[0] @@ -734,6 +738,17 @@ if __name__ == "__main__": os.remove(static_path_js_html5p) if os.path.exists(static_path_js_html5): os.remove(static_path_js_html5) + # 去除搜索页面冗余样式展示 + if os.path.exists(static_path_searchtools): + with open(static_path_searchtools, 'r+', encoding='utf-8') as k: + searchtools_content = k.read() + if new_searchtools_content not in searchtools_content: + new_content_s = searchtools_content.replace(old_searchtools_content, + new_searchtools_content) + if new_content_s != searchtools_content: + k.seek(0) + k.truncate() + k.write(new_content_s) # pylint: disable=W0702 # pylint: disable=W0703