mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
This extension provides the following facilities: - registering modules, - module resolvers, and - an API for retrieving a module instance given its name. A module is defined as a global static structure containing a pointer to a string which is the name of the module, and a pointer to a function which will be called when an instance of the module is needed. A module resolver is a function that accepts a string holding the name of the module and returns a `jerry_value_t` in an out-parameter and `true` if the module was found, or `false` if it was not. If it returns `true` and the out-parameter has the error flag set then the API will pass it through without caching. This extension provides a built-in module resolver which attempts to load modules that follow the above module definition. The API provided by this extension invokes all module resolvers it receives in sequence to attempt to resolve the name of a single module. After one resolver returns `true` and a `jerry_value_t` that represents the module the API stops iterating over the remaining resolvers and caches the value if its error flag is not set. It then returns the `jerry_value_t`. The API will return a `jerry_value_t` containing an error indicating that the module was not found if it reaches the end of the list of resolvers. The error it returns has an extra property `"moduleName"` the value of which is a string containing the name of the module that the API was asked to resolve. JerryScript-DCO-1.0-Signed-off-by: Gabriel Schulhof gabriel.schulhof@intel.com
107 lines
4.2 KiB
Bash
Executable File
107 lines
4.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright JS Foundation and other contributors, http://js.foundation
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
if [ $# -ne 1 ]; then
|
|
echo "Please, specify your gh-pages clone directory: update-webpage <gh-pages clone dir>"
|
|
exit 1
|
|
fi
|
|
|
|
gh_pages_dir=$1
|
|
docs_dir=`dirname $(readlink -f $0)`"/../docs"
|
|
|
|
GETTING_STARTED_MD="01.GETTING-STARTED.md"
|
|
API_REFERENCE_MD="02.API-REFERENCE.md"
|
|
API_EXAMPLES_MD="03.API-EXAMPLE.md"
|
|
INTERNALS_MD="04.INTERNALS.md"
|
|
PORT_API_MD="05.PORT-API.md"
|
|
REFERENCE_COUNTING_MD="06.REFERENCE-COUNTING.md"
|
|
DEBUGGER_MD="07.DEBUGGER.md"
|
|
CODING_STANDARDS_MD="08.CODING-STANDARDS.md"
|
|
EXT_REFERENCE_ARG_MD="09.EXT-REFERENCE-ARG.md"
|
|
EXT_REFERENCE_HANDLER_MD="10.EXT-REFERENCE-HANDLER.md"
|
|
EXT_REFERENCE_AUTORELEASE_MD="11.EXT-REFERENCE-AUTORELEASE.md"
|
|
EXT_REFERENCE_MODULE_MD="12.EXT-REFERENCE-MODULE.md"
|
|
|
|
declare -A titles
|
|
|
|
titles[$GETTING_STARTED_MD]="Getting Started"
|
|
titles[$API_REFERENCE_MD]="API Reference"
|
|
titles[$API_EXAMPLES_MD]="API Examples"
|
|
titles[$INTERNALS_MD]="Internals"
|
|
titles[$PORT_API_MD]="Port API"
|
|
titles[$REFERENCE_COUNTING_MD]="Reference Counting"
|
|
titles[$DEBUGGER_MD]="Debugger"
|
|
titles[$CODING_STANDARDS_MD]="Coding Standards"
|
|
titles[$EXT_REFERENCE_ARG_MD]="'Extension API: Argument Validation'"
|
|
titles[$EXT_REFERENCE_HANDLER_MD]="'Extension API: External Function Handlers'"
|
|
titles[$EXT_REFERENCE_AUTORELEASE_MD]="'Extension API: Autorelease Values'"
|
|
titles[$EXT_REFERENCE_MODULE_MD]="'Extension API: Module Support'"
|
|
|
|
for docfile in $docs_dir/*.md; do
|
|
docfile_base=`basename $docfile`
|
|
|
|
permalink=`echo $docfile_base | cut -d'.' -f 2 | tr '[:upper:]' '[:lower:]'`
|
|
missing_title=`echo $permalink | tr '-' ' '`
|
|
|
|
# the first three documents belong to the navigation bar
|
|
category=$([[ $docfile_base =~ ^0[1-3] ]] && echo "navbar" || echo "documents")
|
|
|
|
# generate appropriate header for each *.md
|
|
echo "---" > $gh_pages_dir/$docfile_base
|
|
echo "layout: page" >> $gh_pages_dir/$docfile_base
|
|
echo "title: ${titles[$docfile_base]:-$missing_title}" >> $gh_pages_dir/$docfile_base
|
|
echo "category: ${category}" >> $gh_pages_dir/$docfile_base
|
|
echo "permalink: /$permalink/" >> $gh_pages_dir/$docfile_base
|
|
echo "---" >> $gh_pages_dir/$docfile_base
|
|
echo >> $gh_pages_dir/$docfile_base
|
|
echo "* toc" >> $gh_pages_dir/$docfile_base
|
|
echo "{:toc}" >> $gh_pages_dir/$docfile_base
|
|
echo >> $gh_pages_dir/$docfile_base
|
|
|
|
# the file itself removing underscores inside links
|
|
gawk \
|
|
'
|
|
!/\[.*\]\(#/ {
|
|
print $0
|
|
}
|
|
|
|
/\[.*\]\(#/ {
|
|
link_start_pos = index($0, "](#");
|
|
line_beg = substr($0, 1, link_start_pos+2);
|
|
line_remain = substr($0, link_start_pos+3);
|
|
link_end_pos = index(line_remain, ")")
|
|
link = substr(line_remain, 1, link_end_pos-1);
|
|
line_end = substr(line_remain, link_end_pos)
|
|
|
|
printf "%s%s%s\n", line_beg, link, line_end
|
|
}
|
|
' $docfile >> $gh_pages_dir/$docfile_base
|
|
|
|
# fix image links
|
|
sed -i -r -e 's/^!\[.*\]\(/&{{ site.github.url }}\//' $gh_pages_dir/$docfile_base
|
|
sed -i -r -e 's/^!\[.*\]\(\{\{ site\.github\.url \}\}\/img.*$/&{: class="thumbnail center-block img-responsive" }/' $gh_pages_dir/$docfile_base
|
|
|
|
# replace span tags to div
|
|
sed -i 's/<span class=/<div class=/g' $gh_pages_dir/$docfile_base
|
|
sed -i 's/<\/span>/<\/div>/g' $gh_pages_dir/$docfile_base
|
|
|
|
# remove table header separators
|
|
sed -i '/^| ---/d' $gh_pages_dir/$docfile_base
|
|
|
|
# update images
|
|
cp -Ru $docs_dir/img $gh_pages_dir
|
|
done
|