<filename>script/BuildDocs.py
﻿#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os, sys, imp, re
import Rylogic as Tools
import HtmlExpand
import UserVars

# Expands '*.htm' files in a directory and copies them to an output directory
# 'src' can be a filepath or a directory. 'dst' must be a directory
def BuildDocs(src:str, dst:str):

	src = os.path.abspath(src)
	dst = os.path.abspath(dst)

	# Export a directory containing 'htm' files
	if os.path.isdir(src):

		# If the file is an '.htm' file, but not an 'include.htm' file
		for filepath in Tools.EnumFiles(src, filter=r".*(?<!include)\.htm$", flags=re.IGNORECASE):

			# Maintain the relative directory structure in 'dstdir'
			relpath = os.path.relpath(filepath, src)
			dir,fname = os.path.split(relpath)
			outdir = os.path.join(dst, dir)

			# Expand the 'htm' file
			HtmlExpand.ExpandHtmlFile(filepath, outdir)

	else:

		# Expand the 'htm' file
		HtmlExpand.ExpandHtmlFile(src, dst)

	return

<filename>script/BuildDocs.py
﻿#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os, sys, imp, re
import Rylogic as Tools
import HtmlExpand
import UserVars

# Expands '*.htm' files in a directory and copies them to an output directory
# 'src' can be a filepath or a directory. 'dst' must be a directory
def BuildDocs(src:str, dst:str):

	src = os.path.abspath(src)
	dst = os.path.abspath(dst)

	# Export a directory containing 'htm' files
	if os.path.isdir(src):

		# If the file is an '.htm' file, but not an 'include.htm' file
		for filepath in Tools.EnumFiles(src, filter=r".*(?<!include)\.htm$", flags=re.IGNORECASE):

			# Maintain the relative directory structure in 'dstdir'
			relpath = os.path.relpath(filepath, src)
			dir,fname = os.path.split(relpath)
			outdir = os.path.join(dst, dir)

			# Expand the 'htm' file
			HtmlExpand.ExpandHtmlFile(filepath, outdir)

	else:

		# Expand the 'htm' file
		HtmlExpand.ExpandHtmlFile(src, dst)

	return

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Expands '*.htm' files in a directory and copies them to an output directory # 'src' can be a filepath or a directory. 'dst' must be a directory # Export a directory containing 'htm' files # If the file is an '.htm' file, but not an 'include.htm' file # Maintain the relative directory structure in 'dstdir' # Expand the 'htm' file # Expand the 'htm' file