-
Notifications
You must be signed in to change notification settings - Fork 362
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
Fix #2687: scripts/makedocs now checks that required software is installed #3778
Draft
LeeTibbert
wants to merge
1
commit into
scala-native:main
Choose a base branch
from
LeeTibbert:PR_doc_makedocs_I2687
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
00_README_ScalaNative_makedocs.utf-8 | ||
|
||
To create html pages for the Scala Native project, run the "makedocs" | ||
script in the "scripts" directory under this project root. | ||
From the "docs" directory, that would be "../scripts/makedocs". | ||
|
||
The script will check for required software, provide the | ||
"sphinx_last_updated_by_git" python module and execute the Makefile | ||
in the "docs" directory. | ||
|
||
A python virtual environment (.venv) is created in the "docs" directory. | ||
That may take up considerable storage space after the documentation | ||
has been built. It may also become outdated or stale if the documentation | ||
has not been built in a few weeks. One may want to get into the habit | ||
of recursively deleting that directory after the last intended | ||
documentation build. The script will recreate it if needed in the future. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,125 @@ | ||
#!/usr/bin/env bash | ||
cd docs | ||
# Create html documentation for the Scala Native project. | ||
# | ||
# | ||
|
||
function popd_handler() { | ||
popd > /dev/null | ||
exit 1 | ||
} | ||
|
||
trap popd_handler ERR | ||
|
||
REQIRED_SOFTWARE="make pip python sphinx-build" | ||
|
||
function sw_exists() { | ||
CMD=$1 | ||
hash $CMD > /dev/null | ||
if [[ $? -ne 0 ]]; then | ||
echo "Required software '$CMD' not found." | ||
echo "required software: $REQUIRED_SOFTWARE" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function check_required_software { | ||
# Even Archimedes needed a lever and a place to stand. | ||
for i in $REQUIRED_SOFTWARE ; do | ||
sw_exists $i | ||
done | ||
} | ||
|
||
function create_venv { | ||
python -m venv .venv | ||
python -m venv .venv | ||
} | ||
|
||
function activate_venv { | ||
source .venv/bin/activate | ||
source .venv/bin/activate | ||
} | ||
|
||
function install_req { | ||
pip install -r ../docs/requirements.txt | ||
function install_sphinx_req { | ||
pip install -r requirements.txt # ${project_root}/docs/ | ||
} | ||
|
||
function generate_docs { | ||
make SPHINX_OPTS="-W" html | ||
make SPHINX_OPTS="-W" html | ||
} | ||
|
||
function usage { | ||
echo " Usage:" | ||
echo " 1. bash makedocs setup # if setup is not done." | ||
echo " 2. bash makedocs # if setup is done and building docs is needed" | ||
} | ||
function setup_docbuild { | ||
# Someday this function should be improved. The .venv file may | ||
# exist but its contends may be outdated or stale. | ||
# Checking for file or directory last access time in a way that | ||
# is robust across platforms is complicated. | ||
# "find" works on Linux, macOS, and probably FreeBSD. | ||
# | ||
# Writing a special python script would probably work across all | ||
# supported operating systems, but that would be beyond the scope | ||
# of the current effort. Such a script could probably replace | ||
# the entire "create" logic of this function. An improvement for | ||
# python literate keeners. | ||
|
||
ACTIVATED=false | ||
if [[ ! -d .venv ]]; then | ||
echo "${PWD}/.venv directory not found, setting it up. Expect pauses." | ||
create_venv | ||
activate_venv | ||
ACTIVATED=true | ||
install_sphinx_req | ||
fi | ||
|
||
if [[ "$ACTIVATED" = false ]]; then | ||
activate_venv | ||
fi | ||
} | ||
|
||
function prepare { | ||
check_required_software | ||
setup_docbuild | ||
} | ||
|
||
## Begin | ||
|
||
# This script expects the directory layout of the Scala Native project. | ||
# This allows running the script from any of a number of reasonably expected | ||
# locations: the project root, the "scripts" sub-directory where it is | ||
# located or the "docs" directory which might cause it to be used. | ||
|
||
DOCDIR="docs" | ||
CWD=${PWD##*/} ## last path element, basename using bash builtins | ||
|
||
if [[ ! -d .git ]]; then # project root, DOCDIR already set correctly | ||
# check likely alternatives | ||
if [[ "$CWD" = "scripts" ]]; then | ||
DOCDIR="../$DOCDIR" | ||
elif [[ "$CWD" = $DOCDIR ]]; then | ||
# Yes, unnecessary but makes the rest of the pushd/popd logic easier. | ||
DOCDIR="." | ||
else | ||
echo "No .git directory found." | ||
echo "Please change directory to project root and try again." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [[ ! -d $DOCDIR ]]; then | ||
echo "Documentaton directory '$DOCDIR' not found." | ||
exit 1 | ||
fi | ||
|
||
pushd $DOCDIR > /dev/null | ||
|
||
if [[ $? -ne 0 ]]; then | ||
echo "Changing to directory '$DOCDIR' failed" | ||
exit 1 | ||
fi | ||
|
||
trap popd_handler ERR | ||
set -e # error if any after this command returns non-zero/fails. | ||
|
||
prepare | ||
|
||
generate_docs | ||
|
||
popd > /dev/null | ||
|
||
case $@ in | ||
"") activate_venv; generate_docs; exit 0 ;; | ||
setup) create_venv; activate_venv; install_req; generate_docs; exit 0 ;; | ||
*) echo "Unknown parameters $@"; usage; exit 1 ;; | ||
esac | ||
## End |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better keep using paths relative to project root directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for looking at this.
In general, I concur that things like
scripts/makedocs
should, after the first mention offrom project root directory
, be assumed and documented as relative.To the best of my knowledge a
file:
URL scheme has to be a fully qualified path. I think having aworking example makes it easier for devos who do not use
file
URLs regularly to check their work.As always, I am open to alternate wording.