Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDDS-6361. Modify docs build flow to replace image tags with shortcod…
…es. (#3122)
- Loading branch information
1 parent
93631a1
commit 17d86f1
Showing
10 changed files
with
84 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
hadoop-hdds/docs/dev-support/bin/make_images_responsive.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import sys | ||
import os | ||
import re | ||
import logging | ||
|
||
LOGLEVEL = os.environ.get('LOGLEVEL', 'WARNING').upper() | ||
logging.basicConfig(level=LOGLEVEL) | ||
|
||
# The first argument to the script is the directory where the documentation is | ||
# stored. | ||
docs_directory = os.path.expanduser(sys.argv[1]) | ||
content_directory = os.path.join(docs_directory, 'content') | ||
|
||
for root, subdirs, files in os.walk(docs_directory): | ||
for filename in files: | ||
# We only want to modify markdown files. | ||
if filename.endswith('.md'): | ||
file_path = os.path.join(root, filename) | ||
|
||
new_file_content = [] | ||
|
||
with open(file_path, 'r', encoding='utf-8') as f: | ||
for line in f: | ||
# If the line contains the image tag, we need to replace it | ||
if re.search(re.compile("^!\[(.*?)\]\((.*?)\)"), line): | ||
logging.debug( | ||
f'file {filename} (full path: {file_path})') | ||
logging.debug(f"found markdown image: {line}") | ||
|
||
line_replacement = line.replace( | ||
'![', '{{< image alt="').replace('](', '" src="').replace(')', '">}}') | ||
|
||
logging.debug( | ||
f"replaced with shortcode: {line_replacement}") | ||
|
||
new_file_content.append(line_replacement) | ||
|
||
else: | ||
new_file_content.append(line) | ||
|
||
with open(file_path, 'w', encoding='utf-8') as f: | ||
f.writelines(new_file_content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters