-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ZEPPELIN-1018] Apply auto "Table of Contents" generator to Zeppelin docs website #1031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
78dca9e
1f10b97
587d4ba
9c5f76b
bef398e
163691c
b05365f
f35db47
db76eb6
fbde57f
6760c00
6a788fe
d114a9d
3fae7df
a03ca99
3ffb383
d00e4b1
6394c70
388f35a
cf0911c
b7cbe5f
04cf501
009579b
e66397b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // https://github.com/ghiculescu/jekyll-table-of-contents | ||
| (function($){ | ||
| $.fn.toc = function(options) { | ||
| var defaults = { | ||
| noBackToTopLinks: false, | ||
| title: '<i></i>', | ||
| minimumHeaders: 2, | ||
| headers: 'h2, h3', | ||
| listType: 'ul', // values: [ol|ul] | ||
| showEffect: 'none', // values: [show|slideDown|fadeIn|none] | ||
| showSpeed: '0', // set to 0 to deactivate effect | ||
| classes: { list: '', | ||
| item: '' | ||
| } | ||
| }, | ||
| settings = $.extend(defaults, options); | ||
|
|
||
| function fixedEncodeURIComponent (str) { | ||
| return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { | ||
| return '%' + c.charCodeAt(0).toString(16); | ||
| }); | ||
| } | ||
|
|
||
| function createLink (header) { | ||
| var innerText = (header.textContent === undefined) ? header.innerText : header.textContent; | ||
| return "<a href='#" + fixedEncodeURIComponent(header.id) + "'>" + innerText + "</a>"; | ||
| } | ||
|
|
||
| var headers = $(settings.headers).filter(function() { | ||
| // get all headers with an ID | ||
| var previousSiblingName = $(this).prev().attr( "name" ); | ||
| if (!this.id && previousSiblingName) { | ||
| this.id = $(this).attr( "id", previousSiblingName.replace(/\./g, "-") ); | ||
| } | ||
| return this.id; | ||
| }), output = $(this); | ||
| if (!headers.length || headers.length < settings.minimumHeaders || !output.length) { | ||
| $(this).hide(); | ||
| return; | ||
| } | ||
|
|
||
| if (0 === settings.showSpeed) { | ||
| settings.showEffect = 'none'; | ||
| } | ||
|
|
||
| var render = { | ||
| show: function() { output.hide().html(html).show(settings.showSpeed); }, | ||
| slideDown: function() { output.hide().html(html).slideDown(settings.showSpeed); }, | ||
| fadeIn: function() { output.hide().html(html).fadeIn(settings.showSpeed); }, | ||
| none: function() { output.html(html); } | ||
| }; | ||
|
|
||
| var get_level = function(ele) { return parseInt(ele.nodeName.replace("H", ""), 10); }; | ||
| var highest_level = headers.map(function(_, ele) { return get_level(ele); }).get().sort()[0]; | ||
| var return_to_top = '<i class="icon-arrow-up back-to-top"> </i>'; | ||
|
|
||
| var level = get_level(headers[0]), | ||
| this_level, | ||
| html = settings.title + " <" +settings.listType + " class=\"" + settings.classes.list +"\">"; | ||
| headers.on('click', function() { | ||
| if (!settings.noBackToTopLinks) { | ||
| window.location.hash = this.id; | ||
| } | ||
| }) | ||
| .addClass('clickable-header') | ||
| .each(function(_, header) { | ||
| this_level = get_level(header); | ||
| if (!settings.noBackToTopLinks && this_level === highest_level) { | ||
| $(header).addClass('top-level-header').after(return_to_top); | ||
| } | ||
| if (this_level === level) // same level as before; same indenting | ||
| html += "<li class=\"" + settings.classes.item + "\">" + createLink(header); | ||
| else if (this_level <= level){ // higher level than before; end parent ol | ||
| for(i = this_level; i < level; i++) { | ||
| html += "</li></"+settings.listType+">" | ||
| } | ||
| html += "<li class=\"" + settings.classes.item + "\">" + createLink(header); | ||
| } | ||
| else if (this_level > level) { // lower level than before; expand the previous to contain a ol | ||
| for(i = this_level; i > level; i--) { | ||
| html += "<" + settings.listType + " class=\"" + settings.classes.list +"\">" + | ||
| "<li class=\"" + settings.classes.item + "\">" | ||
| } | ||
| html += createLink(header); | ||
| } | ||
| level = this_level; // update for the next one | ||
| }); | ||
| html += "</"+settings.listType+">"; | ||
| if (!settings.noBackToTopLinks) { | ||
| $(document).on('click', '.back-to-top', function() { | ||
| $(window).scrollTop(0); | ||
| window.location.hash = ''; | ||
| }); | ||
| } | ||
|
|
||
| render[settings.showEffect](); | ||
| }; | ||
| })(jQuery); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,49 +7,52 @@ group: development | |
|
|
||
| # Contributing to Apache Zeppelin ( Website ) | ||
|
|
||
| ## IMPORTANT | ||
| Apache Zeppelin is an [Apache2 License](http://www.apache.org/licenses/LICENSE-2.0.html) Software. | ||
| Any contribution to Zeppelin (Source code, Documents, Image, Website) means you agree license all your contributions as Apache2 License. | ||
| <div id="toc"></div> | ||
|
|
||
|
|
||
| ## Modifying the website | ||
| This page will give you an overview of how to build and contribute to the documentation of Apache Zeppelin. | ||
| The online documentation at [zeppelin.apache.org](https://zeppelin.apache.org/docs/latest/) is also generated from the files found here. | ||
|
|
||
| #### Getting the source code | ||
| Website is hosted in 'master' branch under `/docs/` dir. | ||
| > **NOTE :** Apache Zeppelin is an [Apache2 License](http://www.apache.org/licenses/LICENSE-2.0.html) Software. | ||
| Any contributions to Zeppelin (Source code, Documents, Image, Website) means you agree with license all your contributions as Apache2 License. | ||
|
|
||
| First of all, you need the website source code. The official location of mirror for Zeppelin is [http://git.apache.org/zeppelin.git](http://git.apache.org/zeppelin.git). | ||
| ## Getting the source code | ||
| First of all, you need Zeppelin source code. The official location of Zeppelin is [http://git.apache.org/zeppelin.git](http://git.apache.org/zeppelin.git). | ||
| Documentation website is hosted in 'master' branch under `/docs/` dir. | ||
|
|
||
| ### git access | ||
|
|
||
| First of all, you need the website source code. The official location of mirror for Zeppelin is [http://git.apache.org/zeppelin.git](http://git.apache.org/zeppelin.git). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think git.apache.org is the actual source code, not a "mirror", but we are told not to have github.com address here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @felixcheung I'm not sure I understood correctly, as you can see in git.apache.org at the first sentence, they said
Am I missing sth ? |
||
| Get the source code on your development machine using git. | ||
|
|
||
| ``` | ||
| git clone git://git.apache.org/zeppelin.git | ||
| cd docs | ||
| ``` | ||
| Apache Zeppelin follows [Fork & Pull](https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/Development-workflow-with-Git:-Fork,-Branching,-Commits,-and-Pull-Request) as a source control workflow. | ||
| If you want to not only build Zeppelin but also make any changes, then you need to fork [Zeppelin github mirror repository](https://github.com/apache/zeppelin) and make a pull request. | ||
|
|
||
| #### Build | ||
|
|
||
| To build, you'll need to install some prerequisites. Please check 'Build documentation' section in [docs/README.md](https://github.com/apache/zeppelin/blob/master/docs/README.md#build-documentation). | ||
| ### Build | ||
|
|
||
| #### Run website in development mode | ||
| You'll need to install some prerequisites to build the code. Please check [Build documentation](https://github.com/apache/zeppelin/blob/master/docs/README.md#build-documentation) section in [docs/README.md](https://github.com/apache/zeppelin/blob/master/docs/README.md). | ||
|
|
||
| While you're modifying website, you'll want to see preview of it. Please check 'Run website' section in [docs/README.md](https://github.com/apache/zeppelin/blob/master/docs/README.md#run-website). | ||
| ### Run website in development mode | ||
|
|
||
| You'll be able to access it on [http://localhost:4000](http://localhost:4000) with your web browser. | ||
| While you're modifying website, you might want to see preview of it. Please check [Run website](https://github.com/apache/zeppelin/blob/master/docs/README.md#run-website) section in [docs/README.md](https://github.com/apache/zeppelin/blob/master/docs/README.md). | ||
| Then you'll be able to access it on [http://localhost:4000](http://localhost:4000) with your web browser. | ||
|
|
||
| #### Making a Pull Request | ||
| ### Making a Pull Request | ||
|
|
||
| When you are ready, just make a pull-request. | ||
|
|
||
|
|
||
| ## Alternative way | ||
|
|
||
| You can directly edit .md files in `/docs/` dir at github's web interface and make pull-request immediatly. | ||
|
|
||
|
|
||
| ## JIRA | ||
| Zeppelin manages its issues in Jira. [https://issues.apache.org/jira/browse/ZEPPELIN](https://issues.apache.org/jira/browse/ZEPPELIN) | ||
| You can directly edit `.md` files in `/docs/` directory at the web interface of github and make pull-request immediatly. | ||
|
|
||
| ## Stay involved | ||
| Contributors should join the Zeppelin mailing lists. | ||
|
|
||
| * [dev@zeppelin.apache.org](http://mail-archives.apache.org/mod_mbox/zeppelin-dev/) is for people who want to contribute code to Zeppelin. [subscribe](mailto:dev-subscribe@zeppelin.apache.org?subject=send this email to subscribe), [unsubscribe](mailto:dev-unsubscribe@zeppelin.apache.org?subject=send this email to unsubscribe), [archives](http://mail-archives.apache.org/mod_mbox/zeppelin-dev/) | ||
|
|
||
| If you have any issues, create a ticket in [JIRA](https://issues.apache.org/jira/browse/ZEPPELIN). | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add license entry of toc.js into
LICENSEfile and make a copy of license underlicensesdirectory, while this file will be included in our source distribution?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Leemoonsoo Yeah I added the license info as you said.