Browse Source

Updated script and docs. Changes include:
- The script can be run from any directory, given that you provide the correct path to the script. Any files and paths that depend on a relative path to the script are explicitly used.
- Added a step to clean the output directory before adding in new files.

Signed-off-by: chanmosq <[email protected]>

chanmosq 2 years ago
parent
commit
4127cac650

+ 10 - 4
tools/o3de-doxygen/README.md

@@ -57,7 +57,7 @@ The C++ API reference generation scripts runs Doxygen on your local `o3de` clone
     ```
    -  **upstream**: Set to track the source repo, [`https://github.com/o3de/o3de.git`](https://github.com/o3de/o3de.git)
 
-1. Run  `git clean` in your local O3DE clone.
+1. Make sure the branch is clean from any untracked files or changes. The branch should be at the same state as the upstream branch's HEAD. To clean, run  `git clean`, `git reset`, or `git stash` as needed.
 
 #### `o3de.org`
 
@@ -69,13 +69,13 @@ The C++ API reference generation scripts runs Doxygen on your local `o3de` clone
     ```
    -  **upstream**: Set to track the source repo, [`https://github.com/o3de/o3de.org.git`](https://github.com/o3de/o3de.org.git)
 
-1. Create a new branch, such as `api-ref`. This branch will contain the API reference docs that you will [generate](#generate) later. 
+1. Create a new branch, such as `api-ref`. This branch will contain the API reference docs that you will [generate](#generate) later.
 
     ```shell
     git switch -c api-ref
     ```
 
-1. Make sure the `api-ref` branch is clean from any untracked files or changes. The branch should be at the same state as the upstream branch's HEAD. To clean, run  `git clean`, `git reset`, or `git stash` as needed.
+1. Make sure the branch is clean from any untracked files or changes. The branch should be at the same state as the upstream branch's HEAD. To clean, run  `git clean`, `git reset`, or `git stash` as needed.
 
 ### Prepare scripts
 
@@ -139,7 +139,13 @@ In some cases, the O3DE API Reference must include the API for code that lives o
 
 To generate API References for Gems outside of `o3de`: 
 
-1. Move the Gem's directory into the `Gems` directory of your local `o3de` clone.
+1. Move or copy the Gem's directory into the `Gems` directory of your local `o3de` clone. 
+
+    To do this using the terminal in your Linux machine, run the following `cp` command with your specified paths. This copies the Gem into the `o3de/Gems/` directory.
+
+    ```shell
+    cp -r <path-to-gem> <path-to>/o3de/Gems
+    ```
 
 2. [Generate the Gems API](#gems-api). 
 

+ 17 - 10
tools/o3de-doxygen/o3de-framework-apis.sh

@@ -1,7 +1,10 @@
 #!/bin/bash
 
-source ./o3de-api-functions.sh
-source ./config.sh
+# Relative path to this script
+REL_PATH=${BASH_SOURCE%/*}
+
+source  ${REL_PATH}/o3de-api-functions.sh
+source ${REL_PATH}/config.sh
 
 # Path to output generated files
 OUTPUT_DIRECTORY=${O3DEORG_PATH}/static/docs/api/frameworks  
@@ -10,19 +13,23 @@ OUTPUT_DIRECTORY=${O3DEORG_PATH}/static/docs/api/frameworks
 FRAMEWORKS=${O3DE_PATH}/Code/Framework
 
 # Frameworks API landing page template
-LANDING_TEMPLATE=framework_index.md
+LANDING_TEMPLATE=${REL_PATH}/framework_index.md
 
 # File to output LANDING_TEMPLATE
 OUTPUT_TOC=${O3DEORG_PATH}/content/docs/api/frameworks/_index.md
 
-# Create Frameworks API landing page (https://www.o3de.org/docs/api/frameworks/)
-# If parent directories don't exist, create them
-if [ ! -e "${OUTPUT_TOC%%/*}" ]; then
-    mkdir -p "${OUTPUT_TOC%%/*}"
+echo "Create Gems API landing page (https://www.o3de.org/docs/api/frameworks/): " ${OUTPUT_TOC}
+if [ ! -e "${OUTPUT_TOC%/*}" ]; then
+    mkdir -p "${OUTPUT_TOC%/*}"
 fi
 cp ${LANDING_TEMPLATE} ${OUTPUT_TOC}
 
-# Generate a set of API docs for each framework
+echo "Clean output directory: " ${OUTPUT_DIRECTORY}
+if [ -d ${OUTPUT_DIRECTORY} ]; then
+    rm -r ${OUTPUT_DIRECTORY}
+fi
+
+echo "Generate a set of API docs for each framework"
 for framework_path in `ls -1d ${FRAMEWORKS}/*/ `; do
 
     # Configure and run Doxygen
@@ -32,7 +39,7 @@ for framework_path in `ls -1d ${FRAMEWORKS}/*/ `; do
     echo "* [${framework}](/docs/api/frameworks/${framework})" >> ${OUTPUT_TOC}
 
     config_file=`mktemp`
-    index="index.md"
+    index="${REL_PATH}/index.md"
 
     echo \
     "
@@ -44,7 +51,7 @@ for framework_path in `ls -1d ${FRAMEWORKS}/*/ `; do
 
     " > $index
 
-    main_config="core-api-doxygen.config"
+    main_config="${REL_PATH}/core-api-doxygen.config"
     if [ -e "${framework}.doxygen" ]; then
         main_config="${framework}.doxygen"
     fi

+ 18 - 11
tools/o3de-doxygen/o3de-gem-apis.sh

@@ -1,7 +1,10 @@
 #!/bin/bash
 
-source ./o3de-api-functions.sh
-source ./config.sh
+# Relative path to this script
+REL_PATH=${BASH_SOURCE%/*}
+
+source  ${REL_PATH}/o3de-api-functions.sh
+source ${REL_PATH}/config.sh
 
 # Path to output generated files
 OUTPUT_DIRECTORY=${O3DEORG_PATH}/static/docs/api/gems  
@@ -10,19 +13,23 @@ OUTPUT_DIRECTORY=${O3DEORG_PATH}/static/docs/api/gems
 GEMS=${O3DE_PATH}/Gems
 
 # Gems API landing page template
-LANDING_TEMPLATE=gems_index.md
+LANDING_TEMPLATE=${REL_PATH}/gems_index.md
 
 # File to output LANDING_TEMPLATE
-OUTPUT_TOC=${O3DEORG_PATH}/content/docs/api/gems/${toc}
+OUTPUT_TOC=${O3DEORG_PATH}/content/docs/api/gems/_index.md
 
-# Create Gems API landing page (https://www.o3de.org/docs/api/gems/)
-# If parent directories don't exist, create them
-if [ ! -e "${OUTPUT_TOC%%/*}" ]; then
-    mkdir -p ${OUTPUT_TOC%%/*}
+echo "Create Gems API landing page (https://www.o3de.org/docs/api/gems/):" ${OUTPUT_TOC}
+if [ ! -e "${OUTPUT_TOC%/*}" ]; then
+    mkdir -p "${OUTPUT_TOC%/*}"
 fi
 cp ${LANDING_TEMPLATE} ${OUTPUT_TOC}
 
-# Generate a set of API docs for each Gem
+echo "Clean output directory: " ${OUTPUT_DIRECTORY}
+if [ -d ${OUTPUT_DIRECTORY} ]; then
+    rm -r ${OUTPUT_DIRECTORY}
+fi
+
+echo "Generate a set of API docs for each Gem"
 for gem_path in `ls -1d ${GEMS}/*/`; do
 
     # Configure and run Doxygen
@@ -32,7 +39,7 @@ for gem_path in `ls -1d ${GEMS}/*/`; do
     echo "* [${gem}](/docs/api/gems/${gem})" >> ${OUTPUT_TOC}
 
     config_file=`mktemp`
-    index=index.md
+    index=${REL_PATH}/index.md
 
     echo \
     "
@@ -43,7 +50,7 @@ for gem_path in `ls -1d ${GEMS}/*/`; do
     Return to the [Gems API Reference](/docs/api/gems) index page. 
     " > $index
 
-    main_config="core-api-doxygen.config"
+    main_config="${REL_PATH}/core-api-doxygen.config"
     if [ -e "${gem}.doxygen" ]; then
         main_config="${gem}.doxygen"
     fi