Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/stdlibs-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: "Build and Push Standard Library Documentation"

on:
workflow_dispatch:
workflow_run:
workflows:
- Java CI
types:
- completed

jobs:
build:
runs-on: ubuntu-latest
outputs:
jolie_version: ${{ steps.jolie_version.outputs.jolie_version }}
summary_string: ${{ steps.generate.outputs.summary_string }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: 21
cache: 'maven'
- name: Build with Maven
run: mvn install --file pom.xml
- name: "Set up JOLIE_HOME environment"
shell: bash
run: |
echo "JOLIE_HOME=${{ github.workspace }}/dist/jolie" >> "$GITHUB_ENV"
- name: Set up PATH environment
shell: bash
run: |
echo "${{ github.workspace }}/dist/launchers/unix" >> $GITHUB_PATH
- name: Generate Documentation
id: generate
shell: bash
run: |
mkdir -p docs
SUMMARY=""
find ${{ github.workspace }}/packages -maxdepth 1 -type f -not -regex ".*_.*" -print | sort | ( while read -r file; do
MODULE_NAME="$(basename -- "$file")"
SERVICE_NAME="$(a=($(cat $file | grep -o -E '^service.*{$'));echo ${a[1]})"

SUMMARY="$SUMMARY - [${MODULE_NAME%.ol}](language-tools-and-standard-library/standard-library-api/${MODULE_NAME%.ol}.md)\n"
# run joliedoc
joliedoc "$file" --internals --out-type md
# insert module name and move necessary file to docs
IPLOCALFILES="$(grep -rnwl 'joliedoc/' --exclude="index.md" --exclude="Overview.md" -e "local")"
# select input port document file
if echo $IPLOCALFILES | tr ' ' '\n'| grep -qiF "$SERVICE_NAME"; then
# try find the file by service name
IPLOCALFILE="$(echo $IPLOCALFILES | tr ' ' '\n' | grep -iF $SERVICE_NAME)"
else
# select first file
IPLOCALFILE="$(echo $IPLOCALFILES | tr ' ' '\n' | head -1)"
fi
# insert service name
sed -i "s/# Service/# Service $SERVICE_NAME\n\n> from ${MODULE_NAME%.ol} import $SERVICE_NAME/" "$IPLOCALFILE"
# move file to docs
mv "$IPLOCALFILE" "${{ github.workspace }}/docs/${MODULE_NAME%.ol}.md"
echo "generated doc for '$file', found '$SERVICE_NAME', moved generated doc file '$IPLOCALFILE' to 'docs/$MODULE_NAME'";

# remove joliedoc
rm -rf ${{ github.workspace }}/joliedoc
done

echo "summary_string<<EOF" >> $GITHUB_OUTPUT
echo "$SUMMARY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT )
- name: Cache Docs
id: cache-docs
uses: actions/cache/save@v4
with:
path: docs
key: docs-${{ github.sha }}
- name: Retrive Jolie version
id: jolie_version
run:
echo "jolie_version=$(cat pom.xml | grep -o -P '(?<=<jolie.version>).*(?=</jolie.version>)')" >> $GITHUB_OUTPUT
push:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
id: cache
with:
path: docs
key: docs-${{ github.sha }}
- name: echo jolie version
run: echo ${{ needs.build.outputs.jolie_version }}
- name: get jolie docs branch
id: jolie_branch
run: echo "jolie_branch=v$(echo ${{ needs.build.outputs.jolie_version }} | sed -E 's/(.*)([[:digit:]]+)/\1x/')" >> $GITHUB_OUTPUT
- name: Push to docs repository
env:
API_TOKEN_GITHUB: ${{ secrets.JOLIE_DOCS_WRITE_CONTENTS }}
BRANCH: ${{ steps.jolie_branch.outputs.jolie_branch }}
DOC_PATH: src/language-tools-and-standard-library/standard-library-api
run: |
CLONE_DIR=$(mktemp -d)
DEST_COPY=$CLONE_DIR/$DOC_PATH
echo "Clone docs repository"
git config --global user.email "[email protected]"
git config --global user.name "GitAction"
git clone --single-branch --branch "$BRANCH" "https://x-access-token:[email protected]/jolie/docs.git" "$CLONE_DIR"
echo "Copy generated doc to docs repository"
mkdir -p "$DEST_COPY"
cp -R "docs" "$DEST_COPY"
cd "$CLONE_DIR"

# replace SUMMARY.md
SUMMARY="${{ needs.build.outputs.summary_string }}"

sed -z -i "s|/standard-library-api/README.md).*# Errors|/standard-library-api/README.md)\n$SUMMARY\n\n# Errors|" src/SUMMARY.md

echo "Add git commit"
git add .
if git status | grep -q "Changes to be committed"
then
git commit --message "Update stdlib docs from Jolie commit/${GITHUB_SHA}"
echo "Pushing git commit"
git push -u origin HEAD:"$BRANCH"
else
echo "No changes detected"
fi
2 changes: 1 addition & 1 deletion include/metajolie.iol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type GetMetaDataRequest: void {
}

type GetMetaDataResponse: void {
.service: Service //< the definition of the service
.service*: Service //< the definition of the service
.input*: Port //< the definitions of all the input ports
.output*: Port //< the definitions of all the output ports
.interfaces*: Interface //< the definitions of all the interfaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type GetMetaDataRequest: void {
}

type GetMetaDataResponse: void {
.service: Service //< the definition of the service
.service*: Service //< the definition of the service
.input*: Port //< the definitions of all the input ports
.output*: Port //< the definitions of all the output ports
.interfaces*: Interface //< the definitions of all the interfaces
Expand Down
2 changes: 1 addition & 1 deletion packages/metajolie.ol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type GetMetaDataRequest: void {
}

type GetMetaDataResponse: void {
.service: Service //< the definition of the service
.service*: Service //< the definition of the service
.input*: Port //< the definitions of all the input ports
.output*: Port //< the definitions of all the output ports
.interfaces*: Interface //< the definitions of all the interfaces
Expand Down
10 changes: 1 addition & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,7 @@
<directory>${basedir}/tools/joliedoc</directory>
<includes>
<include>joliedoc.ol</include>
<include>cardinality-template.html</include>
<include>native-type-template.html</include>
<include>overview-page-template.html</include>
<include>port-page-template.html</include>
<include>sub-type-template.html</include>
<include>type-template.html</include>
<include>typeinline-template.html</include>
<include>typelink-template.html</include>
<include>index-template.html</include>
<include>templates/**</include>
</includes>
<filtering>true</filtering>
</resource>
Expand Down
73 changes: 39 additions & 34 deletions tools/joliedoc/joliedoc.ol
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ service JolieDoc {

max_files = #files
if ( __port_type == "input" ) {
endname = "IPort.html"
endname = "IPort." + type
} else {
endname = "OPort.html"
endname = "OPort." + type
}
files[ max_files ].filename = ptt.name + endname
files[ max_files ].html = portPage
Expand All @@ -381,42 +381,47 @@ service JolieDoc {
install( Abort => nullProcess )
}

init {
getServiceDirectory@File()( joliedoc_directory )
// loading templates
readFile@File( { filename = joliedoc_directory + "/overview-page-template.html" } )( ovh_template )
readFile@File( { filename = joliedoc_directory + "/port-page-template.html" } )( port_page_template )
readFile@File( { filename = joliedoc_directory + "/index-template.html" } )( index_template )
// loading partials
partials[0].name = "cardinality-template"
readFile@File( { filename = joliedoc_directory + "/cardinality-template.html" } )( partials[0].template )
partials[1].name = "native-type-template"
readFile@File( { filename = joliedoc_directory + "/native-type-template.html" } )( partials[1].template )
partials[2].name = "sub-type-template"
readFile@File( { filename = joliedoc_directory + "/sub-type-template.html" } )( partials[2].template )
partials[3].name = "type-template"
readFile@File( { filename = joliedoc_directory + "/type-template.html" } )( partials[3].template )
partials[4].name = "typeinline-template"
readFile@File( { filename = joliedoc_directory + "/typeinline-template.html" } )( partials[4].template )
partials[5].name = "typelink-template"
readFile@File( { filename = joliedoc_directory + "/typelink-template.html" } )( partials[5].template )

}

main {

if ( #args == 0 || #args > 2 ) {
println@Console( "Usage: joliedoc <filename> [--internals ]")()
if ( #args == 0 ) {
println@Console( "Usage: joliedoc <filename> [ --internals ] [ --out-type 'html|md' ]")()
} else {
println@Console("Generating...")()
internals = false
if ( #args == 2 && args[ 1 ] == "--internals" ) {
internals = true
} else if ( #args == 2 ) {
println@Console("Argument " + args[ 1 ] + " not recognized" )()
throw( Abort )
type = "html"
for ( i=0, i< #args, i++ ) {
if ( i == 0 ){
rq.filename = args[ i ]
} else {
if ( args[ i ] == "--internals" ){
internals = true
} else if ( args[ i ] == "--out-type" ){
type = args[ ++i ]
}

}
}
rq.filename = args[ 0 ]

getServiceDirectory@File()( joliedoc_directory )
getFileSeparator@File()(sep)
// loading templates
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "overview-page-template.mustache" } )( ovh_template )
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "port-page-template.mustache" } )( port_page_template )
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "index-template.mustache" } )( index_template )
// loading partials
partials[0].name = "cardinality-template"
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "cardinality-template.mustache" } )( partials[0].template )
partials[1].name = "native-type-template"
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "native-type-template.mustache" } )( partials[1].template )
partials[2].name = "sub-type-template"
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "sub-type-template.mustache" } )( partials[2].template )
partials[3].name = "type-template"
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "type-template.mustache" } )( partials[3].template )
partials[4].name = "typeinline-template"
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "typeinline-template.mustache" } )( partials[4].template )
partials[5].name = "typelink-template"
readFile@File( { filename = joliedoc_directory + sep + "templates" + sep + type + sep + "typelink-template.mustache" } )( partials[5].template )

getInputPortMetaData@MetaJolie( rq )( meta_description )
__port_type = "input"
_get_ports
Expand Down Expand Up @@ -451,7 +456,7 @@ service JolieDoc {
getIndexPage@RenderDocPages( index_rq )( index )

max_files = #files
files[ max_files ].filename = "index.html"
files[ max_files ].filename = "index." + type
files[ max_files ].html = index

/* creating overview */
Expand Down Expand Up @@ -570,7 +575,7 @@ service JolieDoc {
max_files = #files

getOverviewPage@RenderDocPages( ovh_template_req )( ovw )
files[ max_files ].filename = "Overview.html"
files[ max_files ].filename = "Overview." + type
files[ max_files ].html = ovw
}

Expand Down
1 change: 1 addition & 0 deletions tools/joliedoc/templates/md/cardinality-template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{#cardinality}}[{{min}},{{infinite}}{{max}}]{{/cardinality}}
106 changes: 106 additions & 0 deletions tools/joliedoc/templates/md/index-template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<html>

<head>
<style>
body {
font-family: 'Courier New';
font-size: 14px;
}

.headertable {
width: 100%;
font-size: 30px;
padding: 10px;
border-bottom: 1px dotted #444;
}

.menutd {
width: 12%;
border-right: 1px dotted #444;
height: 1000px;
}

.bodytd {
width: 80%;
}

.bodytd object {
width: 100%;
height: 100vh;
}

.maintable {
width: 100%;
}

.menutitle {
font-weight: bold;
font-size: 20px;
}

.menutd a {
cursor: pointer;
}

.itemmenu {
text-align: center;
width: 100%;
}

.itemmenu a:hover {
color: #600;
}
</style>
<script>
function loadPage(page) {
document.getElementById("bodytd").innerHTML = '<object type=\"text/html\" data=\"' + page + '\"></object>';
}
</script>
</head>

<body>
<table class='headertable'>
<tr>
<td>Jolie Documentation:&nbsp;<b>{{filename}}</b></td>
</tr>
</table>
<table class='maintable'>
<tr>
<td valign='top' class='menutd'><br><br>
<table width='100%'>
<tr>
<td class='itemmenu'><a onclick='loadPage("Overview.html")'>OVERVIEW</a></td>
</tr>
</table><br><br>
<table width='100%'>
<tr>
<td class='itemmenu menutitle'>input ports</td>
</tr>
</table><br>
<table width='100%'>
{{#ipitems}}
<tr>
<td class='itemmenu'><a onclick='loadPage("{{ipname}}IPort.html")'>{{ipname}}</a></td>
</tr>
{{/ipitems}}
</table><br><br>
<table width='100%'>
<tr>
<td class='itemmenu menutitle'>output ports</td>
</tr>
</table><br>
<table width='100%'>
{{#opitems}}
<tr>
<td class='itemmenu'><a onclick='loadPage("{{opname}}OPort.html")'>{{opname}}</a></td>
</tr>
{{/opitems}}
</table><br><br>
</td>
<td id='bodytd' class='bodytd'></td>
</tr>
</table>
</body>
<script>loadPage('Overview.html')</script>

</html>
1 change: 1 addition & 0 deletions tools/joliedoc/templates/md/native-type-template.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{#string_type}}string{{/string_type}}{{#int_type}}int{{/int_type}}{{#double_type}}double{{/double_type}}{{#any_type}}any{{/any_type}}{{#void_type}}void{{/void_type}}{{#raw_type}}raw{{/raw_type}}{{#bool_type}}bool{{/bool_type}}{{#long_type}}long{{/long_type}}
Loading
Loading