Skip to content

Commit

Permalink
update framework
Browse files Browse the repository at this point in the history
  • Loading branch information
fasionchan committed Nov 23, 2018
1 parent f28de42 commit e2644af
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Data Structure Algorithms
3 changes: 2 additions & 1 deletion docs/zh_CN/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
_build
_build/
opt/
4 changes: 3 additions & 1 deletion docs/zh_CN/_templates/baidu_tongji.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% set baidu_analytics_id='546bde70816829fce1e19c74caed940a' %}

<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?3d7584e34115fda9fc343709c57a7130";
hm.src = "https://hm.baidu.com/hm.js?{{ baidu_analytics_id }}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
Expand Down
14 changes: 14 additions & 0 deletions docs/zh_CN/_templates/baidu_ziyuan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
3 changes: 3 additions & 0 deletions docs/zh_CN/_templates/course-ad.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h3>大牛课程</h3>
<img src="{{ pathto('_static/zedhz-course-qrcode.jpg', 1) }}" />
<a href="https://time.geekbang.org/column/intro/48?code=vPMg2o7CvYAvCtdAV7DY5UvvS1DzcRNcImRZy3KzttE%3D">我已加入学习,邀你一起!</a>
15 changes: 8 additions & 7 deletions docs/zh_CN/_templates/disqus.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<script>
{% set disqus_domain='data-structure-algorithms.disqus.com' %}

<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
*/

var disqus_config = function () {
this.page.url = window.location.href; // PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = window.location.pathname; // PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
this.page.url = window.location.href; // PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = window.location.pathname; // PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://data-structure-algorithms.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
var d = document, s = d.createElement('script');
s.src = 'https://{{ disqus_domain }}/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>

Expand Down
11 changes: 11 additions & 0 deletions docs/zh_CN/_templates/google_analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% set google_analytics_id='UA-113160431-5' %}

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ google_analytics_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ google_analytics_id }}');
</script>
9 changes: 9 additions & 0 deletions docs/zh_CN/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{% extends "!layout.html" %}

{% block extrahead %}
{% include 'google_analytics.html' %}
{{ super() }}
{% endblock extrahead %}

{% block document %}
{{ super() }}
{% endblock %}
Expand All @@ -8,12 +13,16 @@
<div style="display: none">
<img src="{{ pathto('_static/' ~ theme_logo, 1) }}" />
</div>

{{ super() }}
{% endblock %}

{% block footer %}
{{ super() }}

{% include 'baidu_tongji.html' %}
{% include 'baidu_ziyuan.html' %}
{% include 'disqus.html' %}
{% endblock %}

{#
Expand Down
14 changes: 7 additions & 7 deletions docs/zh_CN/binary-tree/traverse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
Changelog:
.. meta::
:description lang=zh:
:keywords: 遍历,前序,中序,后序,二叉树,traverse, binary tree, preorder, inorder, postorder

==================
遍历二叉树(递归法)
==================
Expand All @@ -18,7 +22,7 @@

.. literalinclude:: /_src/c/binary-tree/traverse/traverse.c
:caption:
:name: c/send_ether/arguments
:name: binary-tree/traverse/traverse/preorder
:language: c
:lines: 19-43
:linenos:
Expand All @@ -28,7 +32,7 @@

.. literalinclude:: /_src/c/binary-tree/traverse/traverse.c
:caption:
:name: c/send_ether/arguments
:name: binary-tree/traverse/traverse/inorder
:language: c
:lines: 46-70
:linenos:
Expand All @@ -38,15 +42,11 @@

.. literalinclude:: /_src/c/binary-tree/traverse/traverse.c
:caption:
:name: c/send_ether/arguments
:name: binary-tree/traverse/traverse/postorder
:language: c
:lines: 73-97
:linenos:

.. comments
comment something out below
.. meta::
:description lang=zh:
:keywords:
10 changes: 8 additions & 2 deletions docs/zh_CN/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import datetime
# import os
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

Expand All @@ -23,6 +23,7 @@
project = u'DSA'
copyright = u'2018, <a href="https://fasionchan.com">fasionchan</a>'
author = u'fasionchan'
site_domain = os.environ.get('SITE_DOMAIN', 'data-structure-algorithms.readthedocs.io')

# The short X.Y version
version = u'1.0'
Expand All @@ -40,6 +41,9 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
"sphinx.ext.mathjax",
"sphinx_sitemap",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -64,7 +68,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store', '_fragments', 'opt']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
Expand Down Expand Up @@ -197,6 +201,8 @@
'Miscellaneous'),
]

site_url = 'https://%s/zh_CN/latest/' % (site_domain,)

def setup(app):
app.add_stylesheet('css/hide-ad.css')
app.add_stylesheet('css/search-box.css')
5 changes: 5 additions & 0 deletions docs/zh_CN/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. meta::
:description lang=zh:
本专栏收录常用数据结构及算法,附以详细讲解和代码示例。
:keywords: Data Structure, Algorithm, C++, Javascript, Python, 数据结构, 算法

==============
数据结构与算法
==============
Expand Down
13 changes: 12 additions & 1 deletion docs/zh_CN/scripts/auto-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
#
#

SELF_PATH=`realpath "$0"`
SCRIPT_DIR_PATH=`dirname "$SELF_PATH"`
DOC_ROOT_PATH=`dirname "$SCRIPT_DIR_PATH"`
PYENV_PATH="$DOC_ROOT_PATH/opt/pyenv"
BUILD_PATH="$DOC_ROOT_PATH/_build"

BIND_ADDR=dsa.local
sudo ifconfig lo0 alias $BIND_ADDR up
sphinx-autobuild -H $BIND_ADDR . _build/html

rm -rf "$BUILD_PATH"
(
cd "$DOC_ROOT_PATH"
PATH="$PYENV_PATH/bin:$PATH" "$PYENV_PATH/bin/sphinx-autobuild" -H $BIND_ADDR . "$BUILD_PATH/html"
)
33 changes: 33 additions & 0 deletions docs/zh_CN/scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# FileName: setup.sh
# Author: Fasion Chan
# @contact: fasionchan@gmail.com
# @version: $Id$
#
# Description:
#
# Changelog:
#
#

SELF_PATH=`realpath "$0"`
SCRIPT_DIR_PATH=`dirname "$SELF_PATH"`
DOC_ROOT_PATH=`dirname "$SCRIPT_DIR_PATH"`
DOCS_PATH=`dirname "$DOC_ROOT_PATH"`
REPO_PATH=`dirname "$DOCS_PATH"`
PYENV_PATH="$DOC_ROOT_PATH/opt/pyenv"
PIP_PATH="$PYENV_PATH/bin/pip"
REAL_PYENV_PATH="$HOME/opt/pythons/pyenv.sphinx"

if [ ! -e "$REAL_PYENV_PATH" ]; then
mkdir -p "$REAL_PYENV_PATH"
virtualenv -p python3 "$REAL_PYENV_PATH"
fi

if [ ! -e "$PYENV_PATH" ]; then
mkdir -p `dirname "$PYENV_PATH"`
ln -s "$REAL_PYENV_PATH" "$PYENV_PATH"
fi

"$PIP_PATH" install -r "$REPO_PATH/requirements/docs.txt"
"$PIP_PATH" install -r "$REPO_PATH/requirements/docs-dev.txt"
2 changes: 2 additions & 0 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
formats: []
requirements_file: requirements/docs.txt
1 change: 1 addition & 0 deletions requirements/docs-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx-autobuild==0.7.1
2 changes: 2 additions & 0 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sphinx==1.8.2
sphinx-sitemap==0.3.1

0 comments on commit e2644af

Please sign in to comment.