Skip to content

Commit

Permalink
Merge branch 'main' into hb-color-background
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbollar committed Feb 13, 2024
2 parents 2c9c4a7 + 9320ffa commit 76ccd74
Show file tree
Hide file tree
Showing 23 changed files with 240 additions and 1,991 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ jobs:
run: |
npm run docs
- name: read the doc file
run: |
head -n 12 "./docs/js-api.md"
- name: Get Docs content
id: get-docs
run: |
Expand All @@ -69,12 +65,15 @@ jobs:

- name: Update Docs
run: |
rm "./source/pages/03Javascript API.md"
mv -f "../doc/js-api.md" "./source/pages/03Javascript API.md"
rm -rf "./source/js-api*"
cp -a "../doc/js-api" "./source/"
cp -a "../doc/js-api-utils" "./source/"
cp -a "../doc/js-api-extras" "./source/"
ls -al ./source
- name: Commit only if there are changes
run: |
if [[ -n $(git diff --exit-code) ]]; then
if [[ -n $(git status --porcelain) ]]; then
echo "Changes detected. Committing and pushing."
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please read our full contributing guide found on our main site: [here](https://docs.mrjs.io/contribute/)
62 changes: 62 additions & 0 deletions create-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# Define base output directories
output_dir='docs'
js_api_dir="${output_dir}/js-api"
js_api_utils_dir="${output_dir}/js-api-utils"
js_api_extras_dir="${output_dir}/js-api-extras"

# Remove the existing output directories if they exist and create new ones
rm -rf "$js_api_dir" "$js_api_utils_dir" "$js_api_extras_dir"
mkdir -p "$js_api_dir" "$js_api_utils_dir" "$js_api_extras_dir"

# Function to process .js files
process_js_files() {
local source_dir=$1
local output_dir=$2
local ignore_index_js_subdirs=$3
local counter=0 # Local counter for each call

# Construct the base find command to exclude 'index.js' files directly
local find_cmd="find \"$source_dir\" -type f -name '*.js' ! -name 'index.js' ! -name '_*'"

# If ignoring subdirectories with index.js
if [[ "$ignore_index_js_subdirs" == "true" ]]; then
local ignore_dirs=$(find "$source_dir" -mindepth 2 -type f -name 'index.js' -exec dirname {} \; | sort | uniq)
for dir in $ignore_dirs; do
local escaped_dir=$(printf '%q' "$dir")
find_cmd+=" ! -path \"$escaped_dir/*\""
done
fi

eval "$find_cmd" | while read file; do
# Format the counter with leading zeros
printf -v formatted_counter "%03d" $counter

# Generate new Markdown file name by prepending the counter to the base name of the .js file
md_file="${output_dir}/${formatted_counter}$(basename "${file%.js}.md")"

# Extract the title from the Markdown file name, accurately reflecting the original file name
local original_file_name=$(basename "$file" .js)
local title="${original_file_name}"

# Generate Markdown content
{
echo '---'
echo "title: ${title}"
echo '---'
echo "# ${title}"
echo ''
jsdoc2md "$file"
} > "$md_file"
echo "<div class='centered'><a href='https://github.com/volumetrics-io/mrjs/edit/main/$file' target='_blank'>Suggest an edit on GitHub for ${original_file_name}.js</a></div>" >> "$md_file"

# Increment the local counter
((counter++))
done
}

# Process files for each directory
process_js_files "src" "$js_api_dir" true # true to ignore subdirs with index.js for js-api
process_js_files "src/utils" "$js_api_utils_dir" false
process_js_files "src/extras" "$js_api_extras_dir" false
Binary file removed dist/57cf7fc5ff4d6dfc74e4.module.wasm
Binary file not shown.
116 changes: 0 additions & 116 deletions dist/index.html

This file was deleted.

1,371 changes: 0 additions & 1,371 deletions dist/mr.js

This file was deleted.

Loading

0 comments on commit 76ccd74

Please sign in to comment.