<s> import bs4 <EOL> from qisys . test . conftest import * <EOL> import qisys . qixml <EOL> import qidoc . worktree <EOL> class TestDocWorkTree ( qidoc . worktree . DocWorkTree ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , worktree = None ) : <EOL> if not worktree : <EOL> worktree = TestWorkTree ( ) <EOL> super ( TestDocWorkTree , self ) . __init__ ( worktree ) <EOL> def add_templates ( self ) : <EOL> self . add_test_project ( "<STR_LIT>" ) <EOL> @ property <EOL> def tmpdir ( self ) : <EOL> return py . path . local ( self . root ) <EOL> def create_doc_project ( self , name , src = None , <EOL> depends = None , doc_type = "<STR_LIT>" , <EOL> dest = None ) : <EOL> if not depends : <EOL> depends = list ( ) <EOL> if not src : <EOL> src = name <EOL> proj_path = self . tmpdir . join ( * src . split ( "<STR_LIT:/>" ) ) <EOL> proj_path . ensure ( dir = True ) <EOL> project_elem = qisys . qixml . etree . Element ( "<STR_LIT>" ) <EOL> project_elem . set ( "<STR_LIT:version>" , "<STR_LIT:3>" ) <EOL> qidoc_elem = qisys . qixml . etree . Element ( "<STR_LIT>" ) <EOL> qidoc_elem . set ( "<STR_LIT:name>" , name ) <EOL> qidoc_elem . set ( "<STR_LIT:type>" , doc_type ) <EOL> project_elem . append ( qidoc_elem ) <EOL> for dep_name in depends : <EOL> dep_elem = qisys . qixml . etree . Element ( "<STR_LIT>" ) <EOL> dep_elem . set ( "<STR_LIT:name>" , dep_name ) <EOL> qidoc_elem . append ( dep_elem ) <EOL> if dest : <EOL> qidoc_elem . set ( "<STR_LIT>" , dest ) <EOL> qiproject_xml = proj_path . join ( "<STR_LIT>" ) . strpath <EOL> qisys . qixml . write ( project_elem , qiproject_xml ) <EOL> self . worktree . add_project ( src ) <EOL> return self . get_doc_project ( name ) <EOL> def create_sphinx_project ( self , name , src = None , depends = None ) : <EOL> return self . create_doc_project ( name , src = src , depends = depends , <EOL> doc_type = "<STR_LIT>" ) <EOL> def create_doxygen_project ( self , name , src = None , depends = None ) : <EOL> return self . create_doc_project ( name , src = src , depends = depends , <EOL> doc_type = "<STR_LIT>" ) <EOL> def add_test_project ( self , src ) : <EOL> """<STR_LIT>""" <EOL> this_dir = os . path . dirname ( __file__ ) <EOL> src_path = os . path . join ( this_dir , "<STR_LIT>" , src ) <EOL> dest_path = os . path . join ( self . root , src ) <EOL> qisys . sh . copy_git_src ( src_path , dest_path ) <EOL> worktree_project = self . worktree . add_project ( src ) <EOL> doc_project = qidoc . worktree . new_doc_project ( self , worktree_project ) <EOL> return doc_project <EOL> class QiDocAction ( TestAction ) : <EOL> def __init__ ( self ) : <EOL> super ( QiDocAction , self ) . __init__ ( "<STR_LIT>" ) <EOL> self . doc_worktree = TestDocWorkTree ( ) <EOL> def add_test_project ( self , * args , ** kwargs ) : <EOL> return self . doc_worktree . add_test_project ( * args , ** kwargs ) <EOL> def create_sphinx_project ( self , * args , ** kwargs ) : <EOL> return self . doc_worktree . create_sphinx_project ( * args , ** kwargs ) <EOL> def create_doxygen_project ( self , * args , ** kwargs ) : <EOL> return self . doc_worktree . create_doxygen_project ( * args , ** kwargs ) <EOL> def find_link ( html_path , text ) : <EOL> with open ( html_path , "<STR_LIT:r>" ) as fp : <EOL> data = fp . read ( ) <EOL> soup = bs4 . BeautifulSoup ( data ) <EOL> link = soup . find ( "<STR_LIT:a>" , text = text ) <EOL> target = link . attrs [ "<STR_LIT>" ] <EOL> target_path = target . split ( "<STR_LIT:#>" ) [ <NUM_LIT:0> ] <EOL> return target_path <EOL> @ pytest . fixture <EOL> def doc_worktree ( cd_to_tmpdir ) : <EOL> return TestDocWorkTree ( ) <EOL> @ pytest . fixture <EOL> def qidoc_action ( cd_to_tmpdir ) : <EOL> res = QiDocAction ( ) <EOL> return res </s>
