How to use transform_docstring method in autopy

Best Python code snippet using autopy Github


Full Screen

...53 if method is None:54 return fmt = r':attr:`%s`' if isinstance(method, property) else r':meth:`%s`'56 return fmt % name57 def transform_docstring(self,58 docstr: str,59 name: str,60 what: str,61 obj: object) -> str:62 # Tokenize keywords.63 docstr = self.token_re.sub(r':token:`\1`', docstr)64 # Automatically insert attributes for local hyperlinking.65 docstr = self.function_re.sub(r':func:`\1`', docstr)66 docstr = self.class_re.sub(r':class:`\1`', docstr)67 docstr = self.module_re.sub(r':module:`\1`', docstr)68 if what in ("method", "class", "attribute"):69 docstr = self._mono_re(r'[\w()]+').sub(self.sub_method, docstr)70 # Treat `text` as monospace (like Markdown).71 docstr = re.sub(r'([^:]|^)`(.*?)`', r'\1``\2``', docstr,72 flags=re.MULTILINE | re.DOTALL)73 # Automatically italicize "Exceptions:"74 docstr = re.sub(r'(\b)(Exceptions:)', r'\1`\2`', docstr)75 # Automatically format code blocks.76 docstr = re.sub("(\s*\n)+((\n?( |\t)(\w.*))+)",77 "\n::\n" + r'\2', docstr, re.MULTILINE)78 return docstr79class Sphinx(object):80 def __init__(self, app):81 = app82 self.modules = ["autopy.%s" % x for x in autopy.__all__]83 self.nodoc = set()84 self.parser = DocstringMarkdownParser(self.modules)85 def autodoc_process_docstring(self, app: str, what: str, name: str,86 obj: object, options: dict, lines: list):87 if name not in self.nodoc:88 if what == 'module':89 self.nodoc.add(name)90 lines[:] = self.parser.transform_docstring(91 "\n".join(lines), name, what, obj92 ).split("\n")93 else:94 del lines[:]95 def autodoc_process_signature(self, app: str, what: str, name: str,96 obj: object, options: dict, signature: str,97 return_annotation: str):98 module = inspect.getmodule(obj)99 if signature and module:100 # Remove superfluous module name from type signature.101 signature = re.sub(r'%s\.(\w+)' % re.escape(module.__name__),102 r'\1', signature)103 return signature, return_annotation104 # See

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autopy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?