diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 56f34db..ecaebf0 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -1,7 +1,7 @@ import os import shutil -import ps +from rwx import ps CHARSET = 'UTF-8' diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py new file mode 100644 index 0000000..f0a2fe5 --- /dev/null +++ b/rwx/prj/__init__.py @@ -0,0 +1,8 @@ +from os import path + + +class Project: + def __init__(self, file_path: str): + self.file: str = path.realpath(file_path) + self.root: str = path.dirname(self.file) + self.name: str = path.basename(self.root) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py new file mode 100644 index 0000000..290c5d9 --- /dev/null +++ b/rwx/prj/sphinx.py @@ -0,0 +1,27 @@ +from os import path +from sphinx.cmd.build import build_main + +from rwx.fs import wipe +from rwx.prj import Project + + +class SphinxProject(Project): + def __init__(self, file_path: str): + super().__init__(file_path) + + def build(self): + output_root: str = path.join(self.root, 'out') + wipe(output_root) + arguments: list[str] = [ + "-E", + "-j", "2", + "-b", "html", + "-D", "project={}".format(self.name), + "-D", "master_doc={}".format("index"), + "-D", "html_theme={}".format("sphinx_rtd_theme"), + "-c", self.root, + # "-C", + path.join(self.root, self.name), + path.join(output_root, self.name), + ] + build_main(arguments) diff --git a/rwx/project/__init__.py b/rwx/project/__init__.py deleted file mode 100644 index 4fadc71..0000000 --- a/rwx/project/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -import os - - -class Project: - - def __init__(self, root_path: str): - self.root = root_path - - -def from_root_file(file_path: str): - project_file = os.path.realpath(file_path) - project_root = os.path.dirname(project_file) - return Project(project_root) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 6502b21..5b50456 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -1,6 +1,6 @@ import subprocess -import txt +from rwx import txt def get_tuples_args(tuples) -> list[str]: