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
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ public int run() throws PulsarClientException {
JCommander commander = pulsarClientTool.commandParser;
if (commandNames.size() == 0) {
for (Map.Entry<String, JCommander> cmd : commander.getCommands().entrySet()) {
if (cmd.getKey().equals("generate_documentation")) {
continue;
}
generateDocument(cmd.getKey(), commander);
}
} else {
for (String commandName : commandNames) {
if (commandName.equals("generate_documentation")) {
continue;
}
generateDocument(commandName, commander);
}
}
Expand Down
1 change: 1 addition & 0 deletions site2/tools/build-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ node ./scripts/split-swagger-by-version.js

# Generate document for command line tools.
${ROOT_DIR}/site2/tools/pulsar-admin-doc-gen.sh
${ROOT_DIR}/site2/tools/pulsar-client-doc-gen.sh
cd ${ROOT_DIR}/site2/website

rm -rf ${ROOT_DIR}/generated-site/content
Expand Down
1 change: 1 addition & 0 deletions site2/tools/pulsar-admin-doc-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $ROOT_DIR/bin/pulsar-admin documents generate schemas > $ROOT_DIR/site2/website/
$ROOT_DIR/bin/pulsar-admin documents generate packages > $ROOT_DIR/site2/website/brodocs/documents/packages.md

cd $ROOT_DIR/site2/website/brodocs
cp pulsar-admin-manifest.json manifest.json
node brodoc.js

cp index.html $DEST_DIR/tools/pulsar-admin/${VERSION}/
Expand Down
52 changes: 52 additions & 0 deletions site2/tools/pulsar-client-doc-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

ROOT_DIR=$(git rev-parse --show-toplevel)
VERSION=`${ROOT_DIR}/src/get-project-version.py`
DEST_DIR=$ROOT_DIR/generated-site

cd $ROOT_DIR

mkdir -p $DEST_DIR/tools/pulsar-client/${VERSION}
mkdir -p $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules
mkdir -p $ROOT_DIR/site2/website/brodocs/documents

$ROOT_DIR/bin/pulsar-client generate_documentation > $ROOT_DIR/site2/website/brodocs/documents/pulsar-client.md

cd $ROOT_DIR/site2/website/brodocs
cp pulsar-client-manifest.json manifest.json
node brodoc.js

cp index.html $DEST_DIR/tools/pulsar-client/${VERSION}/
cp navData.js stylesheet.css $DEST_DIR/tools/pulsar-client/${VERSION}/
cp scroll.js tabvisibility.js $DEST_DIR/tools/pulsar-client/${VERSION}/
cp favicon.ico $DEST_DIR/tools/pulsar-client/${VERSION}/
mkdir -p $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/bootstrap/dist/css
cp -r $ROOT_DIR/site2/website/node_modules/bootstrap/dist/css/bootstrap.min.css $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/bootstrap/dist/css
mkdir -p $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/font-awesome/css
cp -r $ROOT_DIR/site2/website/node_modules/font-awesome/css/font-awesome.min.css $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/font-awesome/css
mkdir -p $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/highlight.js/styles
cp -r $ROOT_DIR/site2/website/node_modules/highlight.js/styles/default.css $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/highlight.js/styles
mkdir -p $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/jquery/dist
cp -r $ROOT_DIR/site2/website/node_modules/jquery/dist/jquery.min.js $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/jquery/dist/
mkdir -p $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/jquery.scrollto
cp -r $ROOT_DIR/site2/website/node_modules/jquery.scrollto/jquery.scrollTo.min.js $DEST_DIR/tools/pulsar-client/${VERSION}/node_modules/jquery.scrollto


42 changes: 42 additions & 0 deletions site2/website/brodocs/pulsar-admin-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"docs": [
{
"filename": "brokers.md"
},
{
"filename": "broker-stats.md"
},
{
"filename": "clusters.md"
},
{
"filename": "functions.md"
},
{
"filename": "namespaces.md"
},
{
"filename": "ns-isolation-policy.md"
},
{
"filename": "sources.md"
},
{
"filename": "sinks.md"
},
{
"filename": "topics.md"
},
{
"filename": "tenants.md"
},
{
"filename": "resource-quotas.md"
},
{
"filename": "schemas.md"
}
],
"title": "Docs",
"copyright": "<a href='http://pulsar.apache.org/'>Apache Pulsar</a>"
}
9 changes: 9 additions & 0 deletions site2/website/brodocs/pulsar-client-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"docs": [
{
"filename": "pulsar-client.md"
}
],
"title": "Docs",
"copyright": "<a href='http://pulsar.apache.org/'>Apache Pulsar</a>"
}
1 change: 1 addition & 0 deletions site2/website/pages/en/pulsar-admin-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PulsarAdminCli extends React.Component {
<div className="pageContainer">
<Container className="mainContainer documentContainer postContainer" >
<span id="latestVersion" style={{display:'none'}}>{latestVersion}</span>
<span id="clientModule" style={{display: 'none'}}>pulsar-admin</span>
<script src={url}></script>
</Container>
</div>
Expand Down
24 changes: 24 additions & 0 deletions site2/website/pages/en/pulsar-client-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const React = require('react');
const CompLibrary = require('../../core/CompLibrary.js');

const Container = CompLibrary.Container;
const CWD = process.cwd();
const releases = require(`${CWD}/releases.json`);

class PulsarClientCli extends React.Component {
render() {
const latestVersion = releases[0];
const url = "../js/getCliByVersion.js?latestVersion=" + latestVersion;
return (
<div className="pageContainer">
<Container className="mainContainer documentContainer postContainer" >
<span id="latestVersion" style={{display:'none'}}>{latestVersion}</span>
<span id="clientModule" style={{display: 'none'}}>pulsar-client</span>
<script src={url}></script>
</Container>
</div>
);
}
}

module.exports = PulsarClientCli;
1 change: 1 addition & 0 deletions site2/website/static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ window.addEventListener('load', function () {
'<div id="cli-dropdown" class="hide">' +
'<ul id="cli-dropdown-items">' +
'<li><a href="/pulsar-admin-cli?version=' + version + '">Pulsar Admin</a></li>' +
'<li><a href="/pulsar-client-cli?version=' + version + '">Pulsar Client</a></li>' +
'</ul>' +
'</div>' +
'</li>';
Expand Down
30 changes: 21 additions & 9 deletions site2/website/static/js/getCliByVersion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
function getCliByVersion(){
var params = window.location.search
var latestVersion = document.getElementById("latestVersion").textContent
var clientModule = document.getElementById("clientModule").textContent
if (!clientModule) {
clientModule = "pulsar-admin"
}
params = params.replace('?', '')
const paramsList = params.split('&')
var version = 'master'
Expand All @@ -18,18 +22,26 @@ function getCliByVersion(){
var versions = version.split('.')
var majorVersion = parseInt(versions[0])
var minorVersion = parseInt(versions[1])
if ((majorVersion == 2 && minorVersion <= 5) || majorVersion === 1) {
if (version === latestVersion) {
window.location.href = "/docs/en/pulsar-admin"
return
var minMinorVersion = 5
var referenceLink = "/pulsar-admin"
if (clientModule === "pulsar-client") {
minMinorVersion = 7
referenceLink = "/reference-cli-tools/#pulsar-client"
}
if (clientModule === "pulsar-admin") {
if ((majorVersion == 2 && minorVersion <= minMinorVersion) || majorVersion === 1) {
if (version === latestVersion) {
window.location.href = "/docs/en" + referenceLink
return
} else {
window.location.href = "/docs/en/" + version + referenceLink
return
}
} else {
window.location.href = "/docs/en/" + version + "/pulsar-admin"
version = parseInt(versions[0]) + "." + parseInt(versions[1]) + ".0"
window.location.href = "http://pulsar.apache.org/tools/ + " + clientModule + "/" + version + "-SNAPSHOT"
return
}
} else {
version = parseInt(versions[0]) + "." + parseInt(versions[1]) + ".0"
window.location.href = "http://pulsar.apache.org/tools/pulsar-admin/" + version + "-SNAPSHOT"
return
}
}
window.onload=getCliByVersion