From 43b8fe5a3274d649f3ba390fcab204b62fcbb86b Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Fri, 27 May 2022 16:18:31 +0200 Subject: [PATCH] Added some of the doc for usage --- src/bootstraparse/modules/config.py | 6 +++++- src/bootstraparse/modules/context_mngr.py | 7 +++++++ src/bootstraparse/modules/environment.py | 13 +++++++++++++ src/bootstraparse/modules/error_mngr.py | 7 ++++++- src/bootstraparse/modules/export.py | 7 ++++++- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/bootstraparse/modules/config.py b/src/bootstraparse/modules/config.py index ab645aa..dd6c4e6 100644 --- a/src/bootstraparse/modules/config.py +++ b/src/bootstraparse/modules/config.py @@ -1,5 +1,9 @@ # Interprets config files -# You probably want to go to environment to get the loaded config +# The Config will be loaded by the environment at runtime and should be acessed that way +# Usage: +# from bootstraparse.modules.config import ConfigLoader +# config = ConfigLoader([list of config files], extentions=[list of extentions]) +# config['file']['key'] # The ConfigLoader class has load_from_file and load_from_folder methods and __getitem__ for accessing loaded elements import os diff --git a/src/bootstraparse/modules/context_mngr.py b/src/bootstraparse/modules/context_mngr.py index f4eec9e..3e6baa7 100644 --- a/src/bootstraparse/modules/context_mngr.py +++ b/src/bootstraparse/modules/context_mngr.py @@ -4,6 +4,13 @@ # self.content: accessible via __getitem__, __setitem__, add, __len__, __iter__ and __getslice__. # self.optionals: accessible via __rshift__ (remapped to return self.map[other]()) # and self.map: accessible via __invert__ (remapped to return self.optionals) +# Usage: +# from bootstraparse.modules.context_mngr import ContextManager +# ctx = ContextManager() +# ctx.??? +# container = BaseContainer() +# container[number] -> The number element in the content +# "class_insert" >> container[number] -> Get an element from one of the mapped methods import rich from bootstraparse.modules import syntax from bootstraparse.modules.error_mngr import CannotBeContainedError diff --git a/src/bootstraparse/modules/environment.py b/src/bootstraparse/modules/environment.py index 0213015..36ff7ac 100644 --- a/src/bootstraparse/modules/environment.py +++ b/src/bootstraparse/modules/environment.py @@ -2,6 +2,19 @@ # Environment has self._mParams for mandatory parameters, self._sParams for secondary parameters and # self.wasInitialised and integrity_check for debug. # __getattr__ and __setattr__ check for existing super, s or m parameters, returns error if not found. +# Usage: +# from bootstraparse.modules.environment import Environment +# env = Environment() +# env.integrity_check() -> Checks if all mandatory parameters are set. +# env["Config"] -> returns config object +# env["context_mngr"] -> returns context manager object +# env["export_mngr"] -> returns export manager object +# env["global_path"] -> returns global path ??? +# env["user_path"] -> returns user path ??? +# env["site_path"] -> returns site path +# env["export"] -> returns export object ??? +# env["site_crawler"] -> returns site crawler object + from bootstraparse.modules import error_mngr diff --git a/src/bootstraparse/modules/error_mngr.py b/src/bootstraparse/modules/error_mngr.py index 7b8fee8..323cb4a 100644 --- a/src/bootstraparse/modules/error_mngr.py +++ b/src/bootstraparse/modules/error_mngr.py @@ -1,7 +1,12 @@ # Dedicated module for defining and interpreting errors as well as generating error messages # You're probably here for log_message or log_exception. -# They take: message, level="ERROR, "INFO", "WARNING", "DEBUG", "CRITICAL" +# They take: message, level=("ERROR, "INFO", "WARNING", "DEBUG", "CRITICAL") # There's also a dict_check(dic, *args) that returns true if all args are keys in the dict. +# Usage: +# from bootstraparse.modules.error_mngr import log_message, log_exception +# log_message("This is a message", level="INFO") level=("ERROR, "INFO", "WARNING", "DEBUG", "CRITICAL") +# log_exception(Exception("This is an exception"), level="ERROR") +# dict_check({"a": 1, "b": 2}, "a", "b") # returns [True, True] import logging import traceback diff --git a/src/bootstraparse/modules/export.py b/src/bootstraparse/modules/export.py index fbfd446..f76669d 100644 --- a/src/bootstraparse/modules/export.py +++ b/src/bootstraparse/modules/export.py @@ -1,5 +1,10 @@ # Module for final generation of the translated website -# Everything seems important :( +# Usage: +# from bootstraparse.modules.export import ExportManager, ExportRequest, ExportResponse +# rqs = ExportRequest("strucural_elements", "div", "optionals", {"id": "my_id", "class": "my_class"}) +# rsp = ExportResponse("start_string", "end_string") +# em = ExportManager(config_file, template_file) +# em(ExportRequest()) -> ExportResponse() from bootstraparse.modules import config, pathresolver, error_mngr from collections import namedtuple