in DocBuild.py [0:0]
def __init__(self, RootDir, OutputDir, YmlFile):
self.RootDirectory = None
self.YmlFilePathBase = None
self.YmlFilePathOut = None
self.OutputDirectory = None
self.MdFiles = list()
self.Repos = dict()
self.EncodingChecker = EncodingCheck()
self.ExtraContents = dict()
# Convert RootDir to abs and confirm valid
if(RootDir is not None):
if(os.path.isabs(RootDir)):
self.RootDirectory = RootDir
else:
self.RootDirectory = os.path.join(
os.path.abspath(os.getcwd()), RootDir)
self.RootDirectory = os.path.realpath(self.RootDirectory)
if(not os.path.isdir(self.RootDirectory)):
raise Exception(
"Invalid Path for RootDir: {0}".format(self.RootDirectory))
# Convert YmlFile to abs and confirm valid
if(YmlFile is not None):
if(os.path.isabs(YmlFile)):
self.YmlFilePathBase = YmlFile
else:
self.YmlFilePathBase = os.path.join(
os.path.abspath(os.getcwd()), YmlFile)
self.YmlFilePathBase = os.path.realpath(self.YmlFilePathBase)
if(not os.path.isfile(self.YmlFilePathBase)):
raise Exception(
"Invalid Path for YmlFile: {0}".format(self.YmlFilePathBase))
self.YmlFilePathOut = os.path.join(
os.path.dirname(self.YmlFilePathBase), "mkdocs.yml")
# Convert OutputDir to abs and then mkdir if necessary
if(OutputDir is not None):
if(os.path.isabs(OutputDir)):
self.OutputDirectory = OutputDir
else:
self.OutputDirectory = os.path.join(
os.path.abspath(os.getcwd()), OutputDir)
self.OutputDirectory = os.path.realpath(self.OutputDirectory)
if(os.path.basename(self.OutputDirectory) != "docs"):
raise Exception(
"For mkdocs we only support output dir of docs. OutputDir: %s" % self.OutputDirectory)
# set output to the dynamic folder
self.OutputDirectory = os.path.join(OutputDir, DocBuild.DYNFOLDER)
if(not os.path.isdir(self.OutputDirectory)):
logging.debug("Output directory doesn't exist. Making... {0}".format(
self.OutputDirectory))
os.makedirs(self.OutputDirectory)
# add all variables and functions here
self.ExtraContents["version"] = VERSION
self.ExtraContents["buildtime"] = str(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
self.ExtraContents["social"] = [
{"icon": 'fontawesome/brands/github-alt', "link": 'https://github.com/microsoft/mu'}]