def test_setup(rootdir, make_app): srcdir = rootdir / 'test_docs' app = make_app('dummy', srcdir=srcdir) app.builder.build_all() def assert_refnode(node, module_name, class_name, target, reftype=None, domain='mat'): attributes = { 'refdomain': domain, 'reftarget': target, } if reftype is not None: attributes['reftype'] = reftype if module_name is not False: attributes['mat:module'] = module_name if class_name is not False: attributes['mat:class'] = class_name assert_node(node, **attributes) doctree = app.env.get_doctree('index') refnodes = list(doctree.traverse(addnodes.pending_xref)) assert_refnode(refnodes[0], u'test_data', None, u'test_data', u'mod') #assert_refnode(refnodes[1], u'test_data', u'ClassInheritHandle', u'handle') app.cleanup()
def test_with_prefix(make_app, rootdir): srcdir = rootdir / 'roots' / 'test_package_prefix' app = make_app(srcdir=srcdir) app.builder.build_all() content = pickle.loads((app.doctreedir / 'index.doctree').read_bytes()) assert isinstance(content[4], addnodes.desc) assert content[4].astext() == '+package.func(x)\n\nReturns x'
def test_setup(make_app, rootdir): srcdir = rootdir / 'roots' / 'test_autodoc' app = make_app(srcdir=srcdir) app.builder.build_all() content = pickle.loads((app.doctreedir / 'index.doctree').read_bytes()) assert isinstance(content[3], addnodes.desc) assert content[3][0].astext() == 'class target.ClassExample(a)' assert content[3][1].astext() == """Bases: handle
def test_without_prefix(make_app, rootdir): srcdir = rootdir / 'roots' / 'test_package_prefix' confdict = { 'matlab_keep_package_prefix' : False } app = make_app(srcdir=srcdir, confoverrides=confdict) app.builder.build_all() content = pickle.loads((app.doctreedir / 'index.doctree').read_bytes()) assert isinstance(content[4], addnodes.desc) assert content[4].astext() == 'package.func(x)\n\nReturns x'
def test_with_prefix(make_app, rootdir): srcdir = rootdir / 'roots' / 'test_package_links' app = make_app(srcdir=srcdir) app.builder.build_all() content = pickle.loads((app.doctreedir / 'contents.doctree').bytes()) assert isinstance(content[3], addnodes.desc) assert content[3].astext() == 'class +replab.Str\n\nBases: handle\n\nDefines a ‘str’ default method and overloads ‘disp’' assert isinstance(content[5], addnodes.desc) assert content[5].astext() == 'class +replab.Action\n\nBases: +replab.Str\n\nAn action group …\n\n\n\nleftActionself, g, p\n\nReturns the left action'
def test_setup(make_app, rootdir): srcdir = rootdir / 'roots' / 'test_pymat' app = make_app(srcdir=srcdir) app.builder.build_all() content = pickle.loads((app.doctreedir / 'index.doctree').read_bytes()) assert isinstance(content[3], addnodes.desc) assert content[3].astext() == 'func.main()\n\nReturns the answer.' assert isinstance(content[7], addnodes.desc) assert content[7].astext() == 'matsrc.func(x)\n\nReturns x'
def test_setup(make_app, rootdir): srcdir = rootdir / 'roots' / 'test_pymat_common_root' app = make_app(srcdir=srcdir) app.builder.build_all() content = pickle.loads((app.doctreedir / 'index.doctree').read_bytes()) assert isinstance(content[4], addnodes.desc) assert content[4].astext().startswith('class base.PythonClass.PythonClass') assert isinstance(content[8], addnodes.desc) assert content[8].astext().startswith('class base.MatlabClass')
def test_without_prefix(make_app, rootdir): srcdir = rootdir / 'roots' / 'test_package_links' confdict = {'matlab_keep_package_prefix': False} app = make_app(srcdir=srcdir, confoverrides=confdict) app.builder.build_all() content = pickle.loads((app.doctreedir / 'contents.doctree').read_bytes()) assert isinstance(content[3], addnodes.desc) assert content[3].astext( ) == 'class replab.Str\n\nBases: handle\n\nDefines a ‘str’ default method and overloads ‘disp’' assert isinstance(content[5], addnodes.desc) assert content[5].astext( ) == 'class replab.Action\n\nBases: replab.Str\n\nAn action group …\n\n\n\nleftAction(self, g, p)\n\nReturns the left action'
def app(test_params, app_params, make_app, shared_result): """ Based on sphinx.testing.fixtures.app """ args, kwargs = app_params assert 'srcdir' in kwargs kwargs['srcdir'].makedirs(exist_ok=True) (kwargs['srcdir'] / 'conf.py').write_text('') app_ = make_app(*args, **kwargs) yield app_ print('# testroot:', kwargs.get('testroot', 'root')) print('# builder:', app_.builder.name) print('# srcdir:', app_.srcdir) print('# outdir:', app_.outdir) print('# status:', '\n' + app_._status.getvalue()) print('# warning:', '\n' + app_._warning.getvalue()) if test_params['shared_result']: shared_result.store(test_params['shared_result'], app_)
def app(test_params, app_params, make_app, shared_result): """ Based on sphinx.testing.fixtures.app """ args, kwargs = app_params assert "srcdir" in kwargs kwargs["srcdir"].makedirs(exist_ok=True) (kwargs["srcdir"] / "conf.py").write_text("") app_ = make_app(*args, **kwargs) yield app_ print("# testroot:", kwargs.get("testroot", "root")) print("# builder:", app_.builder.name) print("# srcdir:", app_.srcdir) print("# outdir:", app_.outdir) print("# status:", "\n" + app_._status.getvalue()) print("# warning:", "\n" + app_._warning.getvalue()) if test_params["shared_result"]: shared_result.store(test_params["shared_result"], app_)
def app(make_app): # Create app to setup build environment srcdir = rootdir / 'test_docs' app = make_app(srcdir=srcdir) doc.MatObject.basedir = app.config.matlab_src_dir return app
def make_app_setup(**conf) -> Sphinx: (tmp_path / "conf.py").write_text("") return make_app(srcdir=STP(tmp_path), confoverrides=conf)
def app_no_setup(make_app, tmp_path) -> Sphinx: (tmp_path / "conf.py").write_text("") return make_app(srcdir=STP(tmp_path))