#!/bin/bash
# TOC_PATTERN exists in index.html files to mark a placeholder for the Table of Contents (TOC) table.
# It's automatically written to index.md template, which is used to generate index.html files.
# It may also be manually added to code comments, by using the Doxygen /mainpage command.
TOC_PATTERN=o3de-doxygen-insert-table
# Link to Related Pages page
function find_pages() {
local line="
Related Pages | The list related documentation pages. | "
[ -f $API_PATH/pages.html ] && DOXY_PAGES=$line || DOXY_ANNOTATED=""
}
function find_modules() {
local line="Modules | The list all modules. | "
[ -f $API_PATH/modules.html ] && DOXY_MODULES=$line || DOXY_ANNOTATED=""
}
# Link to Namespaces List page
function find_namespace_list() {
local line="Namespace List | The list all documented namedspaces. | "
[ -f $API_PATH/namespaces.html ] && DOXY_NAMESPACELIST=$line || DOXY_ANNOTATED=""
}
# Link to Namespaces Members page
function find_namespace_members() {
local line="Namespace Members | The list all documented namedspace members. | "
[ -f $API_PATH/namespacemembers.html ] && DOXY_NAMESPACEMEMBERS=$line || DOXY_ANNOTATED=""
}
# Link to Class List page
function find_annotated() {
local line="Class List | The list of classes, structs, unions, and interfaces. | "
[ -f $API_PATH/classes.html ] && DOXY_ANNOTATED=$line || DOXY_ANNOTATED=""
}
# Link to Class Index page
function find_classes() {
local line="Class Index | The list of classes, structs, unions, and interfaces. | "
[ -f $API_PATH/classes.html ] && DOXY_CLASSES=$line || DOXY_CLASSES=""
}
# Link to Class Members page
function find_functions() {
local line="Class Members | The list of class members. | "
[ -f $API_PATH/functions.html ] && DOXY_FUNCTIONS=$line || DOXY_FUNCTIONS=""
}
# Link to Class Hierarchy page
function find_hierarchy() {
local line="Class Hierarchy | The class hierarchy based on inheritance. | "
[ -f $API_PATH/hierarchy.html ] && DOXY_HIERARCHY=$line || DOXY_HIERARCHY=""
}
# Link to File List page
function find_files() {
local line="File List | The list of all documented files. | "
[ -f $API_PATH/files.html ] && DOXY_FILELIST=$line || DOXY_HIERARCHY=""
}
# Link to File List page
function find_file_members() {
local line="File Members | The list of all documented file members. | "
[ -f $API_PATH/globals.html ] && DOXY_FILEMEMBERS=$line || DOXY_HIERARCHY=""
}
# Link to File List page
function find_examples() {
local line="File Members | The list of all documented examples. | "
[ -f $API_PATH/examples.html ] && DOXY_EXAMPLES=$line || DOXY_HIERARCHY=""
}
function generate_toc () {
API_PATH="$1"
API_NAME="$2"
SECTION="Sections
\nRefer to the following sections of the $API_NAME API Reference.
"
BEGIN_TABLE="\n\nSection | Description |
\n"
END_TABLE="
"
# To hold links to generated pages
DOXY_PAGES=""
DOXY_MODULES=""
DOXY_NAMESPACELIST=""
DOXY_NAMESPACEMEMBERS=""
DOXY_ANNOTATED=""
DOXY_CLASSES=""
DOXY_FUNCTIONS=""
DOXY_HIERARCHY=""
DOXY_FILELIST=""
DOXY_FILEMEMBERS=""
DOXY_EXAMPLES=""
# Set links to DOXY_ variables
find_pages
find_modules
find_namespace_list
find_namespace_members
find_annotated # Sets $DOXY_ANNOTATED
find_classes # Sets $DOXY_CLASSES
find_functions # Sets $DOXY_FUNCTIONS
find_hierarchy # Sets $DOXY_HIERARCHY
find_files
find_file_members
find_examples
# Create the table of contents string
# This is in one line due to issues using multi-line vars with sed
LINE="$SECTION$BEGIN_TABLE$DOXY_PAGES$DOXY_MODULES$DOXY_NAMESPACELIST$DOXY_NAMESPACEMEMBERS$DOXY_ANNOTATED$DOXY_CLASSES$DOXY_FUNCTIONS$DOXY_HIERARCHY$DOXY_FILELIST$DOXY_FILEMEMBERS$DOXY_EXAMPLES$END_TABLE"
# Find $PATTERN in index.html and replace with $LINE
sed -i "/$TOC_PATTERN/ c\\$LINE" $API_PATH/index.html
}