-
Notifications
You must be signed in to change notification settings - Fork 179
Generate Ballerina By Examples
A script is used to take the source of the Ballerina By Examples (BBEs) from the ballerina-distribution
repository as the input and generates the HTML files to be published on the Ballerina website.
-
Download and install Node.js.
-
Navigate to the directory, which includes the script.
Note: The scripts can be found in the
bbe-generation-v2
branch.
cd .github/scripts/bbe
- Install the dependencies.
npm install
- Navigate back to the root of the repo.
cd ../../..
You can do either of the below.
- Delete all the HTML files located in the
learn/by-examples
directory excluding the404.html
andindex.html
files by executing the command below.
find learn/by-example -type f \( -name "*.html" ! -name "404.html" ! -name "index.html" \) -delete
- Delete only the BBEs that you want to update from the
learn/by-examples
directory.
The convertMarkdown.js
script is used to convert the BBE content written in markdown to HTML.
Location from root of the website repo | .github/scripts/bbe/convertMarkdown.js |
Inputs |
1. Location of the examples directory.2. Location of the output to be saved. |
Outputs | HTML files corresponding to the markdown BBE files. |
From the root of the ballerina-dev-website
repository, run the script using Node.js.
node .github/scripts/bbe/convertMarkdown.js <relative_path_to_examples> <relative_path_for_output_HTMLs>
By default, the arguments of the above command will have the values below.
-
<relative_path_to_examples>
=“examples”
-
<relative_path_for_output_HTMLs>
=“learn/by-example”
An example command would be as follows.
node .github/scripts/bbe/convertMarkdown.js "../ballerina-distribution/examples" "learn/by-example"
Note: Generated output BBE HTML files will be saved in the specified directory.
Execute the command below to generate the YAML file with the BBE navigation content.
node .github/scripts/bbe/generateNav.js <relative_path_to_examples> <relative_path_to_data_directory>
An example command would be as follows.
node .github/scripts/bbe/generateNav.js "examples" "\_data"
Deploy the generated HTML files on the Ballerina website by replacing the <ballerina-dev-website>/learn/by-example
directory and verify your changes locally.
This script is used to automate the above manual process of generating the BBEs for the Next.js
-based website. All the changes made in the BBEs would be saved locally in the swan-lake/by-example
directory.
Note: This script clones the
ballerina-distribution
repository locally.
Before running the script, install the dependencies from the root of the project via the command below.
npm install
Execute the command below to run the generateBBEs.js
script.
node .github/scripts/bbe/generateBBEs.js;