Commit adddb837 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Adding option to not expand paths

parent 08434c27
Loading
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -68,7 +68,7 @@ if [ -f "frontmatter.md" ] && [ "$(cat frontmatter.md | tr -d ' \n\t')" != "{}"
  cat spec.md
  cat spec.md
  frontmatterClause=True
  frontmatterClause=True
fi
fi
python3 /markdownTools/processMDSpec.py "./${SPEC_NAME}.md" > combined.md
python3 /markdownTools/processMDSpec.py --no-expand-paths "./${SPEC_NAME}.md" > combined.md
echo "------ Generate input for mkdocs --------"
echo "------ Generate input for mkdocs --------"
#python3 $1 -it -ihp --title ${9^^} "./$8.md"
#python3 $1 -it -ihp --title ${9^^} "./$8.md"
if [ $frontmatterClause == True ]; then
if [ $frontmatterClause == True ]; then
@@ -85,6 +85,16 @@ cat _nav.yml
echo "  - 'Home': 'index.md'" >> mkdocs.yml
echo "  - 'Home': 'index.md'" >> mkdocs.yml
cat _nav.yml >> mkdocs.yml
cat _nav.yml >> mkdocs.yml
cp docs/0.md docs/index.md
cp docs/0.md docs/index.md
repo_url="https://${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
echo ${repo_url}
sed -i 's/##PROJECT/'${CI_PROJECT_NAME^^}'/g' mkdocs.yml
repo_url=$(echo ${repo_url} | sed 's/\//\\\//g')
sed -i 's/##REPO_URL/'"${repo_url}"'/g' mkdocs.yml
sed -i 's/##REPO_NAME/'${CI_PROJECT_NAME^^}'/g' mkdocs.yml

sed --version

cat mkdocs.yml
## Create download tab if official baseline version
## Create download tab if official baseline version
if [[ ${TAG_NAME} == v* ]]; then
if [[ ${TAG_NAME} == v* ]]; then
    echo "\nAdding download tab for version ${TAG_NAME}..."
    echo "\nAdding download tab for version ${TAG_NAME}..."
+10 −6
Original line number Original line Diff line number Diff line
@@ -213,7 +213,7 @@ def processFile(args:argparse.Namespace) -> str:
			The processed markdown content as a string.
			The processed markdown content as a string.
	"""
	"""


	def handleIncludesForFile(filename:str, currentPath:str) -> str:
	def handleIncludesForFile(filename:str, currentPath:str, args:argparse.Namespace) -> str:
		"""	Read a single markdown file and return its content.
		"""	Read a single markdown file and return its content.


			Args:
			Args:
@@ -242,10 +242,13 @@ def processFile(args:argparse.Namespace) -> str:
				print(f'[red]File not found: {filename}')
				print(f'[red]File not found: {filename}')
				raise
				raise


			if args.expandPaths:
			
				# Expand the paths in the markdown file
				# Expand the paths in the markdown file
			
			
				# extract front matter information
				# extract front matter information
				lines = expandPaths(lines, currentPath, dirname)
				lines = expandPaths(lines, currentPath, dirname)
			
			fm, lines = processFrontMatter(lines, args)
			fm, lines = processFrontMatter(lines, args)
			if fm:
			if fm:
				_frontMatter[filename] = fm
				_frontMatter[filename] = fm
@@ -272,13 +275,14 @@ def processFile(args:argparse.Namespace) -> str:


			return ''.join(lines)
			return ''.join(lines)


	return handleIncludesForFile(args.document, os.path.dirname(args.document))
	return handleIncludesForFile(args.document, os.path.dirname(args.document), args)
	
	


def main(args=None):
def main(args=None):


	parser = argparse.ArgumentParser(description='Process markdown specification files.')
	parser = argparse.ArgumentParser(description='Process markdown specification files.')
	parser.add_argument('--no-include', dest='doInclude', action='store_false', default=True, help="don't process include statements")
	parser.add_argument('--no-include', dest='doInclude', action='store_false', default=True, help="don't process include statements")
	parser.add_argument('--no-expand-paths', dest='expandPaths', action='store_false', default=True, help="don't expand paths in the markdown file")
	parser.add_argument('--render-markdown', '-md', dest='renderAsMarkdown', action='store_true',  help='render output as markdown')
	parser.add_argument('--render-markdown', '-md', dest='renderAsMarkdown', action='store_true',  help='render output as markdown')
	parser.add_argument('--process-frontmatter', '-fm', dest='outputFrontMatter', action='store_true',  help='output front matter only')
	parser.add_argument('--process-frontmatter', '-fm', dest='outputFrontMatter', action='store_true',  help='output front matter only')
	parser.add_argument('--frontmatter-only', '-fmo', dest='onlyFrontMatter', action='store_true',  help='output only front matter')
	parser.add_argument('--frontmatter-only', '-fmo', dest='onlyFrontMatter', action='store_true',  help='output only front matter')