21
21
import json
22
22
import re
23
23
24
+ def get_default_mrdocs_src_dir ():
25
+ """
26
+ Returns the default source directory for MrDocs based on the current working directory.
27
+
28
+ If the current working directory is the same as the script directory, it
29
+ means we're working on development. The script is being called from a location
30
+ that's already a MrDocs repository. So the user wants the current directory
31
+ to be used as the source directory, not to create a new source directory
32
+ every time the script is run.
33
+
34
+ If the current working directory is different from the script directory,
35
+ it means we're running the script from a different location, likely a
36
+ pre-existing MrDocs repository. In this case, we assume the user wants to
37
+ create a new source directory for MrDocs in the current working directory
38
+ under the name "mrdocs" or anywhere else in order to avoid conflicts
39
+ and we assume the user is running this whole procedure to bootstrap,
40
+ build, and install MrDocs from scratch.
41
+
42
+ :return: str: The default source directory for MrDocs.
43
+ """
44
+ script_dir = os .path .dirname (os .path .abspath (__file__ ))
45
+ cwd = os .getcwd ()
46
+ if cwd == script_dir :
47
+ return cwd
48
+ else :
49
+ return os .path .join (cwd , "mrdocs" )
50
+
51
+
24
52
@dataclass
25
53
class InstallOptions :
26
54
"""
@@ -39,7 +67,7 @@ class InstallOptions:
39
67
cmake_path : str = ''
40
68
41
69
# MrDocs
42
- mrdocs_src_dir : str = field (default_factory = lambda : os . getcwd () )
70
+ mrdocs_src_dir : str = field (default_factory = get_default_mrdocs_src_dir )
43
71
mrdocs_build_type : str = "Release"
44
72
mrdocs_repo : str = "https://github.com/cppalliance/mrdocs"
45
73
mrdocs_branch : str = "develop"
0 commit comments