From 3355fb9b91e6234235808216db28dc147c9eb38f Mon Sep 17 00:00:00 2001 From: Matt Allen Date: Sun, 15 Sep 2024 16:15:12 -0500 Subject: [PATCH] Add sphinx --- .gitignore | 2 ++ docs/conf.py | 31 +++++++++++++++++++++++++++++++ docs/index.rst | 21 +++++++++++++++++++++ requirements.txt | 1 + src/__init__.py | 6 ++++++ src/orchestrator/__init__.py | 20 ++++++++------------ src/scraper/__init__.py | 1 + 7 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 src/__init__.py diff --git a/.gitignore b/.gitignore index 4b9d59f..241baa5 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,5 @@ data/ .~lock.* .DS_Store + +docs/generated diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..5f41b20 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,31 @@ +import sys +import os +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'indigent-defense-stats' +copyright = '2024, Open Austin' +author = 'Open Austin' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +sys.path.insert(0, os.path.abspath('../src')) + +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary'] + +templates_path = ['_templates'] +exclude_patterns = ['src/tester'] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..e514770 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,21 @@ +.. indigent-defense-stats documentation master file, created by + sphinx-quickstart on Sun Sep 15 15:44:02 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +indigent-defense-stats documentation +==================================== + +Add your content using ``reStructuredText`` syntax. See the +`reStructuredText `_ +documentation for details. + +.. autosummary:: + :toctree: generated + + cleaner + orchestrator + parser + scraper + tools + updater diff --git a/requirements.txt b/requirements.txt index f1aebf0..ee5e98e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ retry == 0.9.2 statistics == 1.0.3.5 xxhash == 3.5.0 flake8 == 7.1.0 +sphinx == 8.0.* diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..58a57ae --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,6 @@ +from . import cleaner +from . import otchestrator +from . import parser +from . import scraper +from . import tools +from . import updater diff --git a/src/orchestrator/__init__.py b/src/orchestrator/__init__.py index 6abfde4..4c7f8c4 100644 --- a/src/orchestrator/__init__.py +++ b/src/orchestrator/__init__.py @@ -1,23 +1,18 @@ import sys, os, csv -# Appends the parent directory of this handler script to the sys.path -current_dir = os.path.dirname(os.path.abspath(__file__)) -parent_dir = os.path.dirname(current_dir) -sys.path.append(parent_dir) - # Import all of the programs modules within the parent_dir -from scraper import scraper -from parser import parser -from cleaner import cleaner -from updater import updater +import scraper +import parser +import cleaner +import updater -class orchestrator: +class Orchestrator: def __init__(self): #Sets our base parameters self.counties = [] self.start_date = '2024-07-01' #Update start date here self.end_date = '2024-07-01' #Update start date here - def orchestrate(self, test): + def orchestrate(self, test: bool = False): #This open the county data CSV to see which counties should be scraped, parsed, cleaned, and updated. with open( @@ -41,4 +36,5 @@ def orchestrate(self, test): updater(c).update() #src/updater print(f"Completed with scraping, parsing, cleaning, and updating of this county: {c}") -orchestrator().orchestrate() +if __name__ == '__main__': + Orchestrator().orchestrate() diff --git a/src/scraper/__init__.py b/src/scraper/__init__.py index fb1e11a..4feec12 100644 --- a/src/scraper/__init__.py +++ b/src/scraper/__init__.py @@ -13,6 +13,7 @@ import importlib class Scraper: + """Scrape Odyssey html files into an output folder""" def __init__(self): pass