Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Automate building of manpages #31

Merged
merged 5 commits into from
Jul 15, 2024

Conversation

luarss
Copy link
Collaborator

@luarss luarss commented Jul 10, 2024

Fixes #7

backend/scrape_docs.py Outdated Show resolved Hide resolved
backend/scrape_docs.py Outdated Show resolved Hide resolved
@luarss luarss force-pushed the feat/scrape-manpage branch 3 times, most recently from a913157 to 105b227 Compare July 11, 2024 12:32
Signed-off-by: Jack Luar <[email protected]>
Copy link
Member

@vvbandeira vvbandeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some breaking down into functions suggestions. This refactor would be good to add CI steps to test these. I will leave it approved, but if you choose to implement some of the features in this PR just request another review.

Comment on lines +80 to +89
# clone repo
or_url = 'https://github.com/The-OpenROAD-Project/OpenROAD'
cur_dir = os.path.dirname(os.path.realpath(__file__))
target_dir = os.path.join(cur_dir, 'OpenROAD')
command = f"git clone {or_url} --depth 1 {target_dir}"
res = subprocess.run(command, shell=True, capture_output=True)
if res.returncode != 0:
print(f"Error in cloning OpenROAD: {res.stderr.decode('utf-8')}")
sys.exit(1)
print('Cloned OpenROAD successfully.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would break this into a function.

Comment on lines +91 to +114
# check if pandoc is installed, if not error out.
res = subprocess.run('pandoc --version', shell=True, capture_output=True)
if res.returncode != 0:
print('Pandoc is not installed. Please install it.')
sys.exit(1)
print('Pandoc is installed.')

# generate manpages
command = '../../etc/find_messages.py > messages.txt'
for module in os.listdir(os.path.join(cur_dir, 'OpenROAD/src')):
path = os.path.join(cur_dir, 'OpenROAD/src', module)
if not os.path.isdir(path):
continue
print('Processing module:', module)
os.chdir(path)
res = subprocess.run(command, shell=True, capture_output=True)
if res.returncode != 0:
print(f"Error in finding messages for {module}: {res.stderr.decode('utf-8')}")
continue
os.chdir(os.path.join(cur_dir, 'OpenROAD/docs'))
num_cores = os.cpu_count()
command = f"make clean && make preprocess && make -j{num_cores}"
res = subprocess.run(command, shell=True, capture_output=True)
print('Finished building manpages.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be another function

Comment on lines +116 to +132
# copy folder contents to data/markdown/manpages
src_dir = os.path.join(cur_dir, 'OpenROAD/docs/md')
dest_dir = os.path.join(cur_dir, 'data/markdown/manpages')
shutil.copytree(src_dir, dest_dir, dirs_exist_ok=True)
print('Copied manpages to data/markdown/manpages.')

# update source_dict
for root, _, files in os.walk(dest_dir):
for file in files:
file_path = os.path.join(root, file)
file_name = os.path.basename(file_path)
source_dict[file_path] = file_name

# change back to the file directory
os.chdir(cur_dir)
shutil.rmtree('OpenROAD')
print('Removed OpenROAD temp directory.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be another function.

@luarss luarss merged commit 79d38f4 into The-OpenROAD-Project:master Jul 15, 2024
5 checks passed
@luarss luarss deleted the feat/scrape-manpage branch July 15, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automate manpage building in docker
2 participants