faker.sphinx.docstring

Module Contents

Classes

ProviderMethodDocstring

Class that preprocesses provider method docstrings to generate sample usage and output

Attributes

logger

_fake

_base_provider_method_pattern

_standard_provider_method_pattern

_locale_provider_method_pattern

_sample_line_pattern

_command_template

_sample_output_template

DEFAULT_SAMPLE_SIZE

DEFAULT_SEED

Sample

faker.sphinx.docstring.logger
faker.sphinx.docstring._fake
faker.sphinx.docstring._base_provider_method_pattern: Pattern
faker.sphinx.docstring._standard_provider_method_pattern: Pattern
faker.sphinx.docstring._locale_provider_method_pattern: Pattern
faker.sphinx.docstring._sample_line_pattern: Pattern
faker.sphinx.docstring._command_template = 'generator.{method}({kwargs})'
faker.sphinx.docstring._sample_output_template = Multiline-String
Show Value
""">>> Faker.seed({seed})
>>> for _ in range({size}):
...     fake.{method}({kwargs})
...
{results}

"""
faker.sphinx.docstring.DEFAULT_SAMPLE_SIZE = 5
faker.sphinx.docstring.DEFAULT_SEED = 0
faker.sphinx.docstring.Sample
class faker.sphinx.docstring.ProviderMethodDocstring(app, what, name, obj, options, lines)

Class that preprocesses provider method docstrings to generate sample usage and output

Notes on how samples are generated: - If the docstring belongs to a standard provider method, sample usage and output will be

generated using a Faker object in the DEFAULT_LOCALE.

  • If the docstring belongs to a localized provider method, the correct locale will be used.

  • If the docstring does not belong to any provider method, docstring preprocessing will be skipped.

  • Docstring lines will be parsed for potential sample sections, and the generation details of each sample section will internally be represented as a Sample namedtuple.

  • Each Sample will have info on the keyword arguments to pass to the provider method, how many times the provider method will be called, and the initial seed value to Faker.seed().

property skipped
property lines
_log_warning(warning)
_parse()
_parse_section(section)
_process_sample_section(section)
_beautify_kwargs(kwargs)
_stringify_result(value)
_generate_eval_scope()
_inject_default_sample_section()
_generate_samples()