diff --git a/docs/_static/css/custom.css b/docs/_static/css/custom.css index 12b153792..463fe16c0 100644 --- a/docs/_static/css/custom.css +++ b/docs/_static/css/custom.css @@ -285,4 +285,8 @@ div.highlight pre, table.highlighttable pre { background: transparent !important; text-decoration: none !important; } + + .highlight .fm { + color: #4fb8ff !important; + } } diff --git a/docs/about.rst b/docs/about.rst index 77a605264..e35bb58e1 100644 --- a/docs/about.rst +++ b/docs/about.rst @@ -10,9 +10,9 @@ The key features are: - **Easy**: Mimesis offers a simple design and clear documentation for easy data generation. - **Multilingual**: Mimesis can generate data in multiple languages. - **Performance**: Widely recognized as the fastest data generator among Python solutions. -- **Data variety**: Mimesis includes various data providers for names, addresses, phone numbers, email addresses, dates, times, and more, catering to different use cases. -- **Country-specific data providers**: Mimesis supports country-specific data providers for generating region-specific data. -- **Extensibility**: Developers can extend Mimesis by creating and integrating their own data providers. +- **Data variety**: Mimesis includes various data providers for names, addresses, phone numbers, email addresses, dates, and more, catering to different use cases. +- **Country-specific data**: Mimesis supports country-specific data providers for generating region-specific data. +- **Extensibility**: You can extend Mimesis by creating and integrating your own data providers. - **Generic data provider**: Mimesis provides a single object that grants easy access to all available data providers in the library. - **Zero hard dependencies**: Mimesis has no hard dependencies, eliminating the need for additional third-party libraries. - **Schema-based generators**: Mimesis offers schema-based data generators to effortlessly produce data of any complexity. diff --git a/docs/providers.rst b/docs/providers.rst index 268d079fd..c98b064dc 100644 --- a/docs/providers.rst +++ b/docs/providers.rst @@ -103,7 +103,7 @@ irrespective of the selected locale. By examining the example provided (the code won't execute), you can see this for yourself: -.. code:: python +.. code-block:: python from mimesis import Person from mimesis.locales import Locale @@ -119,7 +119,7 @@ class structure for all languages and their objects. Here’s how it works: -.. code:: python +.. code-block:: python from mimesis import Generic from mimesis.locales import Locale @@ -132,7 +132,7 @@ Here’s how it works: To modify the default name of the built-in provider, you can change the value of the attribute **Meta.name**: -.. code:: python +.. code-block:: python BrazilSpecProvider.Meta.name = 'brasil' generic.add_provider(BrazilSpecProvider) @@ -142,7 +142,7 @@ To modify the default name of the built-in provider, you can change the value of Or just inherit the class and override the value of attribute *name* of class *Meta* of the provider (in our case this is :class:`~mimesis.builtins.BrazilSpecProvider`) : -.. code:: python +.. code-block:: python class Brasil(BrazilSpecProvider): class Meta: @@ -158,7 +158,7 @@ Generally, you don’t need to add built-it classes to the object demonstrating in which cases you should add a built-in class provider to the object :class:`~mimesis.Generic`. You can use it directly, as shown below: -.. code:: python +.. code-block:: python from mimesis.builtins import RussiaSpecProvider from mimesis.enums import Gender @@ -180,7 +180,7 @@ The library provides support for a wide range of data, which is sufficient for most use cases. However, for those who wish to create their own providers with more specific data, this can be achieved as follows: -.. code:: python +.. code-block:: python from mimesis import Generic from mimesis.locales import Locale @@ -218,7 +218,7 @@ with more specific data, this can be achieved as follows: In addition, you can also add multiple providers: -.. code:: python +.. code-block:: python generic.add_providers(SomeProvider, Another) generic.some_provider.hello() @@ -229,7 +229,7 @@ In addition, you can also add multiple providers: If you attempt to add a provider that does not inherit from :class:`~mimesis.providers.base.BaseProvider`, you will receive a **TypeError** exception: -.. code:: python +.. code-block:: python class InvalidProvider: @staticmethod @@ -237,7 +237,7 @@ you will receive a **TypeError** exception: return 'Hello!' generic.add_provider(InvalidProvider) - Traceback (most recent call last): + ... ... TypeError: The provider must be a subclass of mimesis.providers.BaseProvider. @@ -247,7 +247,7 @@ that only a single instance of the Random object is used. Everything here is quite straightforward, but we would like to clarify one point: the **name** attribute in the **Meta** class refers to the name of the class through which access -to methods of user-class providers is carried out. By default, the class name is used in +to methods of user-class providers is carried out. By default, the class name (``cls.__name__``) is used in lowercase letters. See :ref:`seeded_data` to learn how to access the :class:`~mimesis.random.Random` object. @@ -290,7 +290,7 @@ For example: Afterwards, you will need to create a class that inherits from :class:`~mimesis.providers.base.BaseDataProvider`: -.. code:: python +.. code-block:: python from pathlib import Path @@ -314,10 +314,9 @@ The **Meta** class is required and must contain the following attributes: That’s it! Now you can use your custom data provider: -.. code:: python +.. code-block:: python >>> from mimesis.locales import Locale - >>> cdp = CustomDataProvider(Locale.EN) >>> cdp.my_method() 'value3' diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 0860a575b..e4c636c8d 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -11,7 +11,7 @@ desired method with the appropriate parameters. Consider the following example: -.. code:: python +.. code-block:: python from mimesis import Person from mimesis.locales import Locale @@ -46,7 +46,7 @@ code. Incorrect: -.. code:: python +.. code-block:: python from mimesis import Person, Datetime, Text, Code from mimesis.locales import Locale @@ -59,7 +59,7 @@ Incorrect: Correct: -.. code:: python +.. code-block:: python from mimesis import Generic from mimesis.locales import Locale @@ -73,7 +73,7 @@ Correct: Still correct: -.. code:: python +.. code-block:: python from mimesis import Person from mimesis.locales import Locale @@ -84,7 +84,7 @@ Still correct: Also correct: -.. code:: python +.. code-block:: python from mimesis import Person diff --git a/docs/random_and_seed.rst b/docs/random_and_seed.rst index 0a0f9595e..b761081c4 100644 --- a/docs/random_and_seed.rst +++ b/docs/random_and_seed.rst @@ -51,8 +51,7 @@ to data provider: .. code-block:: python - from mimesis import Person - from mimesis.locales import Locale + from mimesis import Person, Locale person = Person(locale=Locale.TR, seed=0xFF) person.full_name() @@ -67,8 +66,7 @@ method of the :class:`~mimesis.providers.BaseProvider` class .. code-block:: python - from mimesis import Person - from mimesis.locales import Locale + from mimesis import Person, Locale person = Person(Locale.EN, seed='Wow.') @@ -85,8 +83,7 @@ If you want to use the same seed for all your data providers, then using :class: .. code-block:: python - from mimesis import Generic - from mimesis.locales import Locale + from mimesis import Generic, Locale generic = Generic(Locale.EN, seed='Wow. Much seed. Much random.') diff --git a/docs/schema.rst b/docs/schema.rst index 1160d3e71..97838f037 100644 --- a/docs/schema.rst +++ b/docs/schema.rst @@ -172,7 +172,7 @@ while :class:`~mimesis.schema.Field` generates a single value. Let's take a look at the example: -.. code:: python +.. code-block:: python >>> from mimesis import Field, Fieldset, Locale >>> field = Field(locale=Locale.EN) @@ -196,7 +196,7 @@ of a keyword argument **i** for a specific field. Let's take a look at the example: -.. code:: python +.. code-block:: python >>> from mimesis import Fieldset, Locale >>> fs = Fieldset(locale=Locale.EN) @@ -217,7 +217,7 @@ With :class:`~mimesis.schema.Fieldset`, you can create datasets that are similar in structure to your real-world data, allowing you to perform accurate and reliable testing and analysis: -.. code:: python +.. code-block:: python import pandas as pd from mimesis import Fieldset @@ -255,7 +255,7 @@ the final result as the **key** parameter. Let's take a look at the example: -.. code-block:: +.. code-block:: python >>> from mimesis import Field, Fieldset, Locale >>> field = Field(Locale.EN) @@ -290,7 +290,7 @@ it is just a closure which accepts two arguments: **value** and **probability**. Let's take a look at the example: -.. code:: python +.. code-block:: python >>> from mimesis import Fieldset, Locale >>> from mimesis.keys import maybe @@ -303,7 +303,7 @@ In the example above, the probability of generating a **None** value instead of You can use any other value instead of **None**: -.. code:: python +.. code-block:: python >>> from mimesis import Fieldset >>> from mimesis.keys import maybe @@ -323,7 +323,7 @@ data in romanized form, you can make use of the following key function :func:`~m Let's take a look at the example: -.. code:: python +.. code-block:: python >>> from mimesis.schema import Field, Fieldset, Locale >>> from mimesis.keys import romanize @@ -355,7 +355,7 @@ class used to ensure that all key functions accessing random have the same seed. Here is an example of how to do this: -.. code:: python +.. code-block:: python >>> from mimesis import Field >>> from mimesis.locales import Locale @@ -404,7 +404,7 @@ Register Field Handler Suppose you want to create a field that returns a random value from a list of values. First, you need to create a field handler. Let's call it ``my_field``. -.. code:: python +.. code-block:: python def my_field(random, a=None, b=None) -> Any: return random.choice([a, b]) @@ -421,7 +421,7 @@ In this example, we will name the field ``hohoho``. To avoid receiving a ValueError, the field name must be a string that conforms to a valid Python identifier, i.e ``field_name.isidentifier()`` returns ``True``. -.. code:: python +.. code-block:: python >>> from mimesis import Field @@ -433,14 +433,14 @@ In this example, we will name the field ``hohoho``. Note that you can still use a `key function`, but the order of the arguments matters, so the field name comes first, the `key function` second, and then the rest of the keyword arguments (`**kwargs`) that are passed to the field handler: -.. code:: python +.. code-block:: python >>> field("hohoho", key=str.upper, a="a", b="b") 'A' You can register multiple fields at once: -.. code:: python +.. code-block:: python >>> field.register_fields( fields=[ @@ -457,7 +457,7 @@ Unregister Field Handler If you want to unregister a field handler, you can do it like this: -.. code:: python +.. code-block:: python >>> field.unregister_field("hohoho") @@ -465,14 +465,14 @@ Now you can't use it anymore and will get a ``FieldError`` if you try to do so. If you'll attempt to unregister a field that was never registered then nothing going to happen: -.. code:: python +.. code-block:: python >>> field.unregister_field("blabla") # nothing happens It's pretty obvious that you can unregister multiple fields at once as well: -.. code:: python +.. code-block:: python >>> field.unregister_fields( fields=[ @@ -484,7 +484,7 @@ It's pretty obvious that you can unregister multiple fields at once as well: or all fields at once: -.. code:: python +.. code-block:: python >>> field.unregister_all_fields() @@ -496,7 +496,7 @@ Data can be exported in JSON or CSV formats, as well as pickled object represent Let's take a look at the example: -.. code:: python +.. code-block:: python from mimesis.enums import TimestampFormat from mimesis.locales import Locale diff --git a/docs/tips.rst b/docs/tips.rst index ca15ab50f..b27a7d909 100644 --- a/docs/tips.rst +++ b/docs/tips.rst @@ -38,7 +38,7 @@ Let's define the structure of the dummy response. `dummy_endpoints.py`: -.. code:: python +.. code-block:: python from mimesis.schema import Field, Schema from mimesis.locales import Locale @@ -70,7 +70,7 @@ Django Dummy API Endpoint Basically you need just create simple view, which returns `JsonResponse`: -.. code:: python +.. code-block:: python from dummy_endpoints import dummy_users @@ -81,7 +81,7 @@ Basically you need just create simple view, which returns `JsonResponse`: For DRF the same, but in terms of DRF: -.. code:: python +.. code-block:: python from dummy_endpoints import dummy_users @@ -92,7 +92,7 @@ For DRF the same, but in terms of DRF: Response: -.. code:: json +.. code-block:: json [ { @@ -116,7 +116,7 @@ Flask Dummy API Endpoint The same way as above: -.. code:: python +.. code-block:: python from dummy_endpoints import dummy_users @@ -128,7 +128,7 @@ The same way as above: Response: -.. code:: json +.. code-block:: json [ {