#!/usr/bin/env python # Copyright (c) OpenMMLab. All rights reserved. import os import os.path as osp import re from glob import glob def _get_project_docs(): """Get all project document files. Returns: list[str]: file paths """ project_root = osp.join('..', '..', 'projects') pattern = osp.sep.join(['*'] * 2) + '.md' docs = glob(osp.join(project_root, pattern)) docs = [ doc for doc in docs if 'example_project' not in doc and '_CN' not in doc ] return docs def _parse_project_doc_path(fn): """Get project name and banner from a project reference file. Returns: tuple: - project_name (str) - project_banner (str) """ project_banner, project_name = None, None with open(fn, 'r', encoding='utf-8') as f: for line in f.readlines(): if re.match('^( )*', ' ' + banner, '', '
', '' ] project_intro_doc = _get_project_intro_doc() faq_doc = _get_faq_doc() with open( osp.join('projects', 'community_projects.md'), 'w', encoding='utf-8') as f: f.write('# Projects from Community Contributors\n') f.write(''.join(project_intro_doc)) f.write('\n'.join(project_lines)) f.write(''.join(faq_doc)) if __name__ == '__main__': print('collect project documents') main()