Skip to content

Commit d958117

Browse files
committed
Added a snippet of the new function initial_set_up to set up a simple versioning project.
1 parent 596cdb7 commit d958117

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Easy_versioning/main.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,51 @@ def easy_versioning_build():
521521

522522
start_quick_server(link_data[0], link_data[1])
523523

524+
################################################################################## Library utils functions
525+
def initial_set_up():
526+
"""
527+
Simple easy-versioning project set-up.
528+
"""
529+
args = sys.argv[1:] # Takes the parameters from the command line
530+
title = args[0] if len(args) > 0 else "Documentation"
531+
author = args[1] if len(args) > 1 else "Author"
532+
533+
src_path = os.path.join(TEMP_PATH, "src") # "src" folder path
534+
data_path = os.path.join(TEMP_PATH, "data") # "data" folder path
535+
version_paths = [
536+
[os.path.join(TEMP_PATH, "src", "V. 1.0"), "1.0"],
537+
[os.path.join(TEMP_PATH, "src", "V. 2.0"), "2.0"]
538+
] # Versions of the documentation folder
539+
540+
if not os.path.exists(src_path): # If no "src" folder is found
541+
for version in version_paths:
542+
os.makedirs(version[0], exist_ok=True) # Creating the src/version folder
543+
command = [
544+
"sphinx-quickstart",
545+
"--quiet",
546+
"-p", title,
547+
"-a", author,
548+
"-v", version[1],
549+
"--sep"
550+
]
551+
552+
try:
553+
# Running the build command inside of the specific folder
554+
result = subprocess.run(
555+
command, capture_output = True, text = True, cwd = version[0]
556+
)
557+
558+
if result.returncode == 0:
559+
success(f"Sphinx set-up completed for {version[1]}.")
560+
else:
561+
error(f"Sphinx set-up failed for {version[1]}.")
562+
error(f"{result.stderr}.")
563+
except Exception as e:
564+
error(f"Exception during the set-up {e}.")
565+
566+
if not os.path.exists(data_path):
567+
os.makedirs(data_path, exist_ok = True)
568+
524569
################################################################################## Main
525570

526571
if __name__ == "__main__":

0 commit comments

Comments
 (0)