Skip to content

Commit

Permalink
Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
funilrys committed Dec 21, 2020
1 parent b5735e3 commit dea9f29
Show file tree
Hide file tree
Showing 55 changed files with 787 additions and 438 deletions.
32 changes: 27 additions & 5 deletions .travis/complementary/api_file_generation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This is an example which check that the file generation from the API is still
working.
This is an example which let us manipulate the data and also generate the files
as if it was the CLI.
"""

import copy
Expand All @@ -27,10 +27,13 @@
PyFunceble.facility.ConfigLoader.start()


# This is needed as our idea is to communicate with the producer thread instead
# of trying to reimplement everything.
# So, this describes the dataset as they are sent to the tester thread (normally)
STD_COMMUNICATION_DATASET = {
"type": "single",
"subject_type": "domain",
# Destination in the output directory.
# Destination inside the output directory.
"destination": "my_awesome_pyfunceble_wrapper",
"subject": None,
"idna_subject": None,
Expand All @@ -41,34 +44,53 @@

DOMAINS = ["github.com", "twitter.com"]


# In this example, we are cleaning up and regenerating the output directory
# at each run.
dir_structure_restoration = DirectoryStructureRestoration(
parent_dirname=STD_COMMUNICATION_DATASET["destination"]
).restore_from_backup()

# We start the producer thread.
producer_thread = ProducerThread()
producer_thread.start()

# We start and configure our availability checker.
avail_checker = DomainAvailabilityChecker(use_whois_lookup=False)

for domain in DOMAINS:
# We loop through our list of subject to test.

# We parse the current subject to the availability checker.
avail_checker.subject = domain

# Now we fetch the status object.
test_result = avail_checker.get_status()
communication_dataset = copy.deepcopy(STD_COMMUNICATION_DATASET)

# We prepare our communication dataset.
communication_dataset = copy.deepcopy(STD_COMMUNICATION_DATASET)
communication_dataset["subject"] = test_result.subject
communication_dataset["idna_subject"] = test_result.idna_subject

# We print the result (for us as we call this script.)
print(
f"{test_result.idna_subject} (IDNA: {test_result.subject}) "
f"is {test_result.status}"
)

# We order the generation of the status file by putting our information
# to the producer queue.
producer_thread.add_to_the_queue((communication_dataset, test_result))

# We are now done, it's time to send the stop signal.
# The stop signal will inform thhe producer thread that it needs to stop
# listening to new order (from the time it reads the stop signal).
producer_thread.send_stop_signal()

# Now we wait until it's done.
producer_thread.wait()

# From here all files were generated we can do whatever we want with them.

if os.path.isfile(
os.path.join(
dir_structure_restoration.get_output_basedir(), "domains", "ACTIVE", "list"
Expand Down
8 changes: 0 additions & 8 deletions PyFunceble/checker/availability/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,6 @@ def guess_all_settings(self) -> "AvailabilityCheckerBase":

return self

@CheckerBase.query_status_if_missing
def get_status(self) -> Optional[AvailabilityCheckerStatus]:
"""
Provides the current state of the status.
"""

return self.status

def query_syntax_checker(self) -> "AvailabilityCheckerBase":
"""
Queries the syntax checker.
Expand Down
15 changes: 15 additions & 0 deletions PyFunceble/checker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,18 @@ def query_status(self) -> "CheckerBase":
"""

raise NotImplementedError()

@query_status_if_missing
def get_status(self) -> Optional[CheckerStatusBase]:
"""
Provides the current state of the status.
.. note::
This method will automatically query status using the
:meth:`PyFunceble.checker.base.CheckerBase.query_status` if
the
:attr:`PyFunceble.checker.status_base.CheckerStatusBase.status`
attribute is not set.
"""

return self.status
8 changes: 0 additions & 8 deletions PyFunceble/checker/reputation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,6 @@ def should_we_continue_test(self, status_post_syntax_checker: str) -> bool:
or status_post_syntax_checker == PyFunceble.storage.STATUS.invalid
)

@CheckerBase.query_status_if_missing
def get_status(self) -> Optional[ReputationCheckerStatus]:
"""
Provides the current state of the status.
"""

return self.status

def query_syntax_checker(self) -> "ReputationCheckerBase":
"""
Queries the syntax checker.
Expand Down
8 changes: 0 additions & 8 deletions PyFunceble/checker/syntax/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ def subject_propagator(self) -> "CheckerBase":

return self

@CheckerBase.query_status_if_missing
def get_status(self) -> Optional[SyntaxCheckerStatus]:
"""
Provides the current state of the status.
"""

return self.status

@CheckerBase.ensure_subject_is_given
@CheckerBase.update_status_date_after_query
def query_status(self) -> "SyntaxCheckerBase":
Expand Down
12 changes: 3 additions & 9 deletions PyFunceble/cli/scripts/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,23 +356,17 @@ def update_documentation() -> "ProductionPrep":
header = "Code Documentation"
source_code_destination = os.path.join(docs_dir_helper.realpath, "code")

current_dir = docs_dir_helper.get_current()

CommandHelper(
f"sphinx-apidoc -f -H {header!r} -M -P -o "
f"sphinx-apidoc -d 5 -f -H {header!r} -M -P -o "
f"{source_code_destination!r} {source_code_dir_helper.realpath}"
).execute(raise_on_error=True)

os.chdir(docs_dir_helper.realpath)

docs_destination = os.path.join(docs_dir_helper.realpath, "_build")
docs_destination = os.path.join(docs_dir_helper.realpath, "_build", "html")

CommandHelper(
f"sphinx-build -a -Q {docs_dir_helper.realpath!r} {docs_destination}"
f"sphinx-build -a -Q {docs_dir_helper.realpath!r} {docs_destination!r}"
).execute(raise_on_error=False)

os.chdir(current_dir)

def update_code_urls(self) -> "ProductionPrep":
"""
Updates all URL in the source code.
Expand Down
2 changes: 1 addition & 1 deletion PyFunceble/data/infrastructure/.PyFunceble_production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ cli_testing:
# `\.info`.
file_filter: null

# Activates the mining.
# Activates the mining of data.
mining: False

# Acknowleadges that we may test for local network component.
Expand Down
2 changes: 1 addition & 1 deletion PyFunceble/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from PyFunceble.storage_facility import get_config_directory

PROJECT_NAME: str = "PyFunceble"
PROJECT_VERSION: str = "4.0.0a6.dev (Blue Duckling)"
PROJECT_VERSION: str = "4.0.0a7.dev (Blue Duckling)"

DISTRIBUTED_CONFIGURATION_FILENAME: str = ".PyFunceble_production.yaml"
DISTRIBUTED_DIR_STRUCTURE_FILENAME: str = "dir_structure_production.json"
Expand Down
138 changes: 134 additions & 4 deletions docs/api/endpoints.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,139 @@
Enpoints
--------
Available Checkers
------------------

Before starting to play with any checkers you need to understand 2 things:

- :class:`~PyFunceble.checker.base.CheckerBase`
- :class:`~PyFunceble.checker.status_base.CheckerStatusBase`

The first one is the base of all checkers, and the second is the base of all
status you get when you call the
:meth:`~PyFunceble.checker.base.CheckerBase.get_status` method.

Availability checkers
^^^^^^^^^^^^^^^^^^^^^

- Domain:
- :class:`PyFunceble.checker.availability.domain.DomainAvailabilityChecker`

or

- :code:`from PyFunceble import DomainAvailabilityChecker`

- Domain and IP:
- :class:`PyFunceble.checker.availability.domain_and_ip.DomainAndIPAvailabilityChecker`

or

- :code:`from PyFunceble import DomainAndIPAvailabilityChecker`


- URL:
- :class:`PyFunceble.checker.availability.url.URLAvailabilityChecker`

or

- :code:`from PyFunceble import URLAvailabilityChecker`

- IP (v4 / v6):
- :class:`PyFunceble.checker.availability.ip.IPAvailabilityChecker`

or

- :code:`from PyFunceble import IPAvailabilityChecker`

Syntax checkers
^^^^^^^^^^^^^^^

- Domain (Second level domain / Subdomain):
- :class:`PyFunceble.checker.syntax.domain.DomainSyntaxChecker`

or

- :code:`from PyFunceble import DomainAvailabilityChecker`

- Second Level Domain:
- :class:`PyFunceble.checker.syntax.second_lvl_domain.SecondLvlDomainSyntaxChecker`

or

- :code:`from PyFunceble import SecondLvlDomainSyntaxChecker`

- Subdomain:
- :class:`PyFunceble.checker.syntax.subdomain.SubDomainSyntaxChecker`

or

- :code:`from PyFunceble import SubDomainSyntaxChecker`

- URL:
- :class:`PyFunceble.checker.syntax.url.URLSyntaxChecker`

or

- :code:`from PyFunceble import URLSyntaxChecker`

- IP (v4 / v6):
- :class:`PyFunceble.checker.syntax.ip.IPSyntaxChecker`

or

- :code:`from PyFunceble import IPSyntaxChecker`

- IPv4
- :class:`PyFunceble.checker.syntax.ipv4.IPv4SyntaxChecker`

or

- :code:`from PyFunceble import IPv4SyntaxChecker`

- IPv6
- :class:`PyFunceble.checker.syntax.ipv6.IPv6SyntaxChecker`

or

- :code:`from PyFunceble import IPv6SyntaxChecker`

Reputation checkers
^^^^^^^^^^^^^^^^^^^

- Domain:
- :class:`PyFunceble.checker.reputation.domain.DomainReputationChecker`

or

- :code:`from PyFunceble import DomainReputationChecker`

- Domain and IP:
- :class:`PyFunceble.checker.reputation.domain_and_ip.DomainAndIPReputationChecker`

or

- :code:`from PyFunceble import DomainAndIPReputationChecker`


- URL:
- :class:`PyFunceble.checker.reputation.url.URLReputationChecker`

or

- :code:`from PyFunceble import URLReputationChecker`

- IP (v4 / v6):
- :class:`PyFunceble.checker.reputation.ip.IPReputationChecker`

or

- :code:`from PyFunceble import IPReputationChecker`

Endpoints
---------

.. note::
This section document what you can call directly when you use PyFunceble as an imported module.

.. warning::
SOme of those methods may be deprecated and removed in the future (open for discussion).

.. automodule:: PyFunceble
:members:
:exclude-members: stay_safe
:members:

0 comments on commit dea9f29

Please sign in to comment.