Skip to content

Commit

Permalink
docs(common): deploy docs if component version got changed
Browse files Browse the repository at this point in the history
  • Loading branch information
suren-gabrielyan-espressif committed May 3, 2023
1 parent 31187b7 commit fc7cc07
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 62 deletions.
68 changes: 44 additions & 24 deletions .github/workflows/publish-docs-component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,47 @@ jobs:
tag_name: ${{ env.BUMP_TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Generate docs
# shell: bash
# run: |
# sudo apt-get update
# sudo apt-get -y install doxygen clang python3-pip
# python -m pip install breathe recommonmark esp-docs==1.4.1
# cd $GITHUB_WORKSPACE/docs
# ./generate_docs
# - name: Deploying generated docs
# if: always()
# shell: bash
# run: |
# source $GITHUB_WORKSPACE/docs/utils.sh
# add_doc_server_ssh_keys $DOCS_DEPLOY_KEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
# export GIT_VER=$(git describe --always)
# export GITHUB_REF_NAME=latest
# export DOCS_BUILD_DIR=$GITHUB_WORKSPACE/docs
# deploy-docs
# - name: Upload components to component service
# uses: espressif/github-actions/upload_components@master
# with:
# directories: "components/esp_modem;components/esp_websocket_client;components/mdns;components/asio;components/esp_mqtt_cxx"
# namespace: "espressif"
# api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
- name: Check if the document exists
id: document_check
if: env.BUMP_VERSION != ''
shell: bash
run: |
if [[ ${{ env.BUMP_COMPONENT } == "mdns" ]]; then
URL=$DOCS_DEPLOY_URL_BASE/${{ env.BUMP_COMPONENT }}/docs/${{ env.BUMP_VERSION }}/en/index.html
else
URL=$DOCS_DEPLOY_URL_BASE/${{ env.BUMP_COMPONENT }}/docs/${{ env.BUMP_VERSION }}/index.html
fi
# Send a GET request to the web page and store the response status code in a variable
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${URL}")
# Check if the response status code is 200
if [ "${HTTP_STATUS}" -ne 200 ]; then
echo "::set-output name=exist::no"
fi
- name: Generate docs
if: ${{ steps.document_check.outputs.exist == 'no' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get -y install doxygen clang python3-pip
python -m pip install breathe recommonmark esp-docs==1.4.1
cd $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }}
./generate_docs ${{ env.BUMP_VERSION }}
- name: Deploying generated docs
if: ${{ steps.document_check.outputs.exist == 'no' }}
shell: bash
run: |
source $GITHUB_WORKSPACE/docs/utils.sh
add_doc_server_ssh_keys $DOCS_DEPLOY_KEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
export GIT_VER=$(git describe --always)
export GITHUB_REF_NAME=latest
export DOCS_BUILD_DIR=$GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }}
export DOCS_DEPLOY_PATH=$DOCS_DEPLOY_PATH/${{ env.BUMP_COMPONENT }}
deploy-docs
export GITHUB_REF_NAME=${{ env.BUMP_VERSION }}
deploy-docs
- name: Upload components to component service
uses: espressif/github-actions/upload_components@master
with:
directories: "components/esp_modem;components/esp_websocket_client;components/mdns;components/asio;components/esp_mqtt_cxx"
namespace: "espressif"
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
54 changes: 47 additions & 7 deletions docs/asio/generate_docs
Original file line number Diff line number Diff line change
@@ -1,26 +1,66 @@
#!/bin/bash

rm -rf docs

if [ "$#" -eq 1 ]; then
NEW_RELEASE=$1
fi

build-docs --target esp32 --language en

cp -rf _build/en/esp32/html .
mkdir -p docs/generic
mv _build/en/esp32/html docs/generic

rm -rf _build __pycache__

if [ -n NEW_RELEASE ]; then
URL="https://docs.espressif.com/projects/esp-protocols/asio/docs/latest/index.html"
RELEASES=$(curl $URL | awk '/var RELEASES = \[/,/];/' | sed 's/var RELEASES = \[//' | sed 's/];$//' | tr -d '",')
RELEASES+=(\'$NEW_RELEASE\')
fi

NEW_RELEASES=()
for element in "${RELEASES[@]}"; do
NEW_RELEASES+=("$element,")
done
echo ${NEW_RELEASES[@]}

# Modifes some version and target fields of index.html
echo "<script type="text/javascript">
window.onload =(function() {
var myAnchor = document.getElementById('version-select');
var mySpan = document.createElement('input');
mySpan.setAttribute('type', 'text');
mySpan.setAttribute('maxLength', '10');
mySpan.value = 'latest';
mySpan.setAttribute('disabled', true);
var mySpan = document.createElement('select');
mySpan.style.float = 'left';
var latest_ver = document.createElement('option');
latest_ver.value = 'latest';
latest_ver.textContent = 'latest(master)';
mySpan.append(latest_ver);
var RELEASES = [
$(echo ${NEW_RELEASES[@]})
];
for (var i = RELEASES.length - 1; i >= 0; i--) {
var current_ver = document.createElement('option');
current_ver.value = RELEASES[i];
current_ver.textContent = 'release-'+ RELEASES[i];
mySpan.append(current_ver);
}
myAnchor.parentNode.replaceChild(mySpan, myAnchor);
mySpan.addEventListener('change', function() {
window.location.href='https://docs.espressif.com/projects/esp-protocols/asio/docs/'+event.target.value+'/index.html'
});
var myAnchor = document.getElementById('target-select');
var mySpan = document.createElement('input');
mySpan.style.float = 'left';
mySpan.setAttribute('type', 'text');
mySpan.setAttribute('maxLength', '10');
mySpan.value = 'all targets';
mySpan.setAttribute('disabled', true);
myAnchor.parentNode.replaceChild(mySpan, myAnchor);
})();
</script>" >> html/index.html
</script>" | tee -a docs/generic/html/index.html > /dev/null
28 changes: 16 additions & 12 deletions docs/esp_modem/generate_docs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Cleanup the generated html
rm -rf html
rm -rf html docs

# Generate C++ API header of the DCE
cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc | clang++ -E -P -CC -xc++ -I../../components/esp_modem/include -DGENERATE_DOCS - | sed -n '1,/DCE command documentation/!p' > en/esp_modem_dce.hpp
Expand All @@ -13,27 +13,31 @@ cat ../../components/esp_modem/include/generate/esp_modem_command_declare.inc |

build-docs --target esp32 --language en

cp -rf _build/en/esp32/html .
rm -rf _build __pycache__
mkdir -p docs/generic
mv _build/en/esp32/html docs/generic

rm -rf _build __pycache__

# Modifes some version and target fields of index.html
echo "<script type='text/javascript'>
# Modifes some version and target fields of index.html
echo "<script type="text/javascript">
window.onload =(function() {
var myAnchor = document.getElementById('version-select');
var mySpan = document.createElement('select');
mySpan.style.float = 'left';

latest_ver = document.createElement('option');
var latest_ver = document.createElement('option');
latest_ver.value = 'latest';
latest_ver.textContent = 'latest(master)';
mySpan.append(latest_ver);

var myArray = ['v1.0.0''];
for (var i = myArray.length - 1; i >= 0; i--) {
current_ver = document.createElement('option');
current_ver.value = myArray[i];
current_ver.textContent = 'release-'+myArray[i];
var RELEASES = [
'v0.1.9',
'v1.0.0'
];
for (var i = RELEASES.length - 1; i >= 0; i--) {
var current_ver = document.createElement('option');
current_ver.value = RELEASES[i];
current_ver.textContent = 'release-'+ RELEASES[i];
mySpan.append(current_ver);
}

Expand All @@ -53,4 +57,4 @@ window.onload =(function() {
myAnchor.parentNode.replaceChild(mySpan, myAnchor);

})();
</script>" >> html/index.html
</script>" | tee -a docs/generic/html/index.html > /dev/null
36 changes: 29 additions & 7 deletions docs/esp_mqtt_cxx/generate_docs
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
rm -rf docs

build-docs --target esp32 --language en

cp -rf _build/en/esp32/html .
mkdir -p docs/generic
mv _build/en/esp32/html docs/generic

rm -rf _build __pycache__

# Modifes some version and target fields of index.html
echo "<script type="text/javascript">
window.onload =(function() {
var myAnchor = document.getElementById('version-select');
var mySpan = document.createElement('input');
mySpan.setAttribute('type', 'text');
mySpan.setAttribute('maxLength', '10');
mySpan.value = 'latest';
mySpan.setAttribute('disabled', true);
var mySpan = document.createElement('select');
mySpan.style.float = 'left';

var latest_ver = document.createElement('option');
latest_ver.value = 'latest';
latest_ver.textContent = 'latest(master)';
mySpan.append(latest_ver);

var RELEASES = [
'v0.1.0'
];
for (var i = RELEASES.length - 1; i >= 0; i--) {
var current_ver = document.createElement('option');
current_ver.value = RELEASES[i];
current_ver.textContent = 'release-'+ RELEASES[i];
mySpan.append(current_ver);
}


myAnchor.parentNode.replaceChild(mySpan, myAnchor);
mySpan.addEventListener('change', function() {
window.location.href='https://docs.espressif.com/projects/esp-protocols/esp_mqtt_cxx/docs/'+event.target.value+'/index.html'
});

var myAnchor = document.getElementById('target-select');
var mySpan = document.createElement('input');
mySpan.style.float = 'left';
mySpan.setAttribute('type', 'text');
mySpan.setAttribute('maxLength', '10');
mySpan.value = 'all targets';
mySpan.setAttribute('disabled', true);
myAnchor.parentNode.replaceChild(mySpan, myAnchor);

})();
</script>" >> html/index.html
</script>" | tee -a docs/generic/html/index.html > /dev/null
36 changes: 29 additions & 7 deletions docs/esp_websocket_client/generate_docs
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
rm -rf docs

build-docs --target esp32 --language en

cp -rf _build/en/esp32/html .
mkdir -p docs/generic
mv _build/en/esp32/html docs/generic

rm -rf _build __pycache__

# Modifes some version and target fields of index.html
echo "<script type="text/javascript">
window.onload =(function() {
var myAnchor = document.getElementById('version-select');
var mySpan = document.createElement('input');
mySpan.setAttribute('type', 'text');
mySpan.setAttribute('maxLength', '10');
mySpan.value = 'latest';
mySpan.setAttribute('disabled', true);
var mySpan = document.createElement('select');
mySpan.style.float = 'left';

var latest_ver = document.createElement('option');
latest_ver.value = 'latest';
latest_ver.textContent = 'latest(master)';
mySpan.append(latest_ver);

var RELEASES = [
'v1.0.0'
];
for (var i = RELEASES.length - 1; i >= 0; i--) {
var current_ver = document.createElement('option');
current_ver.value = RELEASES[i];
current_ver.textContent = 'release-'+ RELEASES[i];
mySpan.append(current_ver);
}


myAnchor.parentNode.replaceChild(mySpan, myAnchor);
mySpan.addEventListener('change', function() {
window.location.href='https://docs.espressif.com/projects/esp-protocols/esp_websocket_client/docs/'+event.target.value+'/index.html'
});

var myAnchor = document.getElementById('target-select');
var mySpan = document.createElement('input');
mySpan.style.float = 'left';
mySpan.setAttribute('type', 'text');
mySpan.setAttribute('maxLength', '10');
mySpan.value = 'all targets';
mySpan.setAttribute('disabled', true);
myAnchor.parentNode.replaceChild(mySpan, myAnchor);

})();
</script>" >> html/index.html
</script>" | tee -a docs/generic/html/index.html > /dev/null
Loading

0 comments on commit fc7cc07

Please sign in to comment.