Best Python code snippet using lisa_python
documentor.py
Source:documentor.py  
...45def _write(fh, s):46    return fh.write(s.encode('utf-8'))47def _hide_edit_on_github(fh):48    _write(fh, ':github_url: hide\n\n')49def _write_title(fh, title, level=1):50    if not isinstance(level, int) or level < 1 or level > 5:51        raise ValueError('`level` must be an integer from 1 to 5')52    if level <= 2:53        _write(fh, SECTION_ADORNMENTS[level - 1] * len(title))54        _write(fh, '\n')55    _write(fh, '{}\n'.format(title))56    _write(fh, SECTION_ADORNMENTS[level - 1] * len(title))57    _write(fh, '\n\n')58def _write_standard_provider_index():59    fname = os.path.join(DOCS_ROOT, 'providers.rst')60    with open(fname, 'wb') as fh:61        _hide_edit_on_github(fh)62        _write_title(fh, 'Standard Providers')63        _write(fh, '.. toctree::\n')64        _write(fh, '   :maxdepth: 2\n\n')65        _write(fh, '   providers/baseprovider\n')66        for provider_name in STANDARD_PROVIDER_NAMES:67            _write(fh, '   providers/{}\n'.format(provider_name))68def _write_base_provider_docs():69    fname = os.path.join(DOCS_ROOT, 'providers', 'baseprovider.rst')70    with open(fname, 'wb') as fh:71        _hide_edit_on_github(fh)72        _write_title(fh, '``faker.providers``')73        _write(fh, PROVIDER_AUTODOC_TEMPLATE.format(74            provider_class='faker.providers.BaseProvider',75            provider_methods=','.join(BASE_PROVIDER_METHOD_NAMES),76        ))77def _write_standard_provider_docs():78    for provider_name in STANDARD_PROVIDER_NAMES:79        fname = os.path.join(DOCS_ROOT, 'providers', '%s.rst' % provider_name)80        with open(fname, 'wb') as fh:81            provider_class = '{}.Provider'.format(provider_name)82            provider_methods = _get_provider_methods(provider_class)83            _hide_edit_on_github(fh)84            _write_title(fh, '``{}``'.format(provider_name))85            _write(fh, PROVIDER_AUTODOC_TEMPLATE.format(86                provider_class=provider_class,87                provider_methods=provider_methods,88            ))89def _write_localized_provider_index():90    fname = os.path.join(DOCS_ROOT, 'locales.rst')91    with open(fname, 'wb') as fh:92        _hide_edit_on_github(fh)93        _write_title(fh, 'Localized Providers')94        _write(fh, '.. toctree::\n')95        _write(fh, '   :maxdepth: 2\n\n')96        for locale in AVAILABLE_LOCALES:97            _write(fh, '   locales/{}\n'.format(locale))98def _write_localized_provider_docs():99    for locale in AVAILABLE_LOCALES:100        info = _get_localized_provider_info(locale)101        fname = os.path.join(DOCS_ROOT, 'locales', '{}.rst'.format(locale))102        with open(fname, 'wb') as fh:103            _hide_edit_on_github(fh)104            _write_title(fh, 'Locale {}'.format(locale))105            for provider_class, standard_provider_name in info:106                provider_methods = _get_provider_methods(provider_class)107                _write_title(fh, '``{}``'.format(standard_provider_name), level=2)108                _write(fh, PROVIDER_AUTODOC_TEMPLATE.format(109                    provider_class=provider_class,110                    provider_methods=provider_methods,111                ))112def write_provider_docs():113    _write_standard_provider_index()114    _write_base_provider_docs()115    _write_standard_provider_docs()116    _write_localized_provider_index()...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
