Skip to content

Commit b5116c7

Browse files
committed
[New] chapter 1
Signed-off-by: PythonShell <pythonshell@yeah.net>
0 parents  commit b5116c7

10 files changed

Lines changed: 317 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_build

‎Makefile‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = GraphvizTutorial
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

‎_static/examples/graph01.dot‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
digraph G {
2+
main -> parse -> execute;
3+
main -> init;
4+
main -> cleanup;
5+
execute -> make_string;
6+
execute -> printf;
7+
execute -> compare;
8+
}

‎_static/examples/graph01.jpg‎

24.4 KB
Loading

‎_static/examples/graph02.dot‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
digraph G {
2+
main [shape=box]; /* this is a comment */
3+
main -> parse [weight=8];
4+
parse-> execute;
5+
main -> init [style=dotted];
6+
main -> cleanup;
7+
execute -> {make_string, printf};
8+
init -> make_string;
9+
edge [ color=red];
10+
main -> printf [style=bold, label="100 times"];
11+
make_string [label = "make a\nstring"];
12+
node [shape=box, style=filled,color=".7, .3, 1.0"];
13+
execute -> compare;
14+
}

‎_static/examples/graph02.jpg‎

28.5 KB
Loading

‎chap01.rst‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
第一章 快速入门
2+
==============================================================================
3+
4+
画一个简单的有向图
5+
------------------------------------------------------------------------------
6+
7+
Graphviz 编译的源文件是 dot 文件,把如下的代码保存到 graph01.dot 文件。
8+
9+
.. code-block:: none
10+
:linenos:
11+
:caption: graph01.dot
12+
:name: Graph 01
13+
14+
digraph G {
15+
main -> parse -> execute;
16+
main -> init;
17+
main -> cleanup;
18+
execute -> make_string;
19+
execute -> printf;
20+
execute -> compare;
21+
}
22+
23+
24+
使用命令 `dot -Tjpg graph01.dot -o graph01.jpg` 编译,可以得到名为 graph01.jpg
25+
的图片,图片内容如下所示。
26+
27+
.. image:: _static/examples/graph01.jpg
28+
29+
30+
让有向图更复杂点
31+
------------------------------------------------------------------------------
32+
33+
Graphviz 可以给点(node)或者线(edge)添加格式。
34+
35+
.. code-block:: none
36+
:linenos:
37+
:caption: graph02.dot
38+
:name: Graph 02
39+
40+
digraph G {
41+
main [shape=box];
42+
main -> parse [weight=8];
43+
parse-> execute;
44+
main -> init [style=dotted];
45+
main -> cleanup;
46+
execute -> {make_string, printf};
47+
init -> make_string;
48+
edge [color=red];
49+
main -> printf [style=bold, label="100 times"];
50+
make_string [label = "make a\nstring"];
51+
node [shape=box, style=filled,color=".7, .3, 1.0"];
52+
execute -> compare;
53+
}
54+
55+
使用命令 `dot -Tjpg graph02.dot -o graph02.jpg` 可以得到如下的图片:
56+
57+
.. image:: _static/examples/graph02.jpg
58+
59+

‎conf.py‎

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Graphviz Tutorial documentation build configuration file, created by
4+
# sphinx-quickstart on Wed Feb 8 20:16:42 2017.
5+
#
6+
# This file is execfile()d with the current directory set to its
7+
# containing dir.
8+
#
9+
# Note that not all possible configuration values are present in this
10+
# autogenerated file.
11+
#
12+
# All configuration values have a default; values that are commented out
13+
# serve to show the default.
14+
15+
# If extensions (or modules to document with autodoc) are in another directory,
16+
# add these directories to sys.path here. If the directory is relative to the
17+
# documentation root, use os.path.abspath to make it absolute, like shown here.
18+
#
19+
# import os
20+
# import sys
21+
# sys.path.insert(0, os.path.abspath('.'))
22+
23+
24+
# -- General configuration ------------------------------------------------
25+
26+
# If your documentation needs a minimal Sphinx version, state it here.
27+
#
28+
# needs_sphinx = '1.0'
29+
30+
# Add any Sphinx extension module names here, as strings. They can be
31+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32+
# ones.
33+
extensions = ['sphinx.ext.todo',
34+
'sphinx.ext.coverage',
35+
'sphinx.ext.mathjax']
36+
37+
# Add any paths that contain templates here, relative to this directory.
38+
templates_path = ['_templates']
39+
40+
# The suffix(es) of source filenames.
41+
# You can specify multiple suffix as a list of string:
42+
#
43+
# source_suffix = ['.rst', '.md']
44+
source_suffix = '.rst'
45+
46+
# The master toctree document.
47+
master_doc = 'index'
48+
49+
# General information about the project.
50+
project = u'Graphviz Tutorial'
51+
copyright = u'2017, Python Shell'
52+
author = u'Python Shell'
53+
54+
# The version info for the project you're documenting, acts as replacement for
55+
# |version| and |release|, also used in various other places throughout the
56+
# built documents.
57+
#
58+
# The short X.Y version.
59+
version = u'1.0'
60+
# The full version, including alpha/beta/rc tags.
61+
release = u'1.0'
62+
63+
# The language for content autogenerated by Sphinx. Refer to documentation
64+
# for a list of supported languages.
65+
#
66+
# This is also used if you do content translation via gettext catalogs.
67+
# Usually you set "language" from the command line for these cases.
68+
language = 'zh_CN'
69+
70+
# List of patterns, relative to source directory, that match files and
71+
# directories to ignore when looking for source files.
72+
# This patterns also effect to html_static_path and html_extra_path
73+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
74+
75+
# The name of the Pygments (syntax highlighting) style to use.
76+
pygments_style = 'sphinx'
77+
78+
# If true, `todo` and `todoList` produce output, else they produce nothing.
79+
todo_include_todos = True
80+
81+
82+
# -- Options for HTML output ----------------------------------------------
83+
84+
# The theme to use for HTML and HTML Help pages. See the documentation for
85+
# a list of builtin themes.
86+
#
87+
#html_theme = 'alabaster'
88+
html_theme = 'sphinxdoc'
89+
90+
# Theme options are theme-specific and customize the look and feel of a theme
91+
# further. For a list of options available for each theme, see the
92+
# documentation.
93+
#
94+
# html_theme_options = {}
95+
96+
# Add any paths that contain custom static files (such as style sheets) here,
97+
# relative to this directory. They are copied after the builtin static files,
98+
# so a file named "default.css" will overwrite the builtin "default.css".
99+
html_static_path = ['_static']
100+
101+
102+
# -- Options for HTMLHelp output ------------------------------------------
103+
104+
# Output file base name for HTML help builder.
105+
htmlhelp_basename = 'GraphvizTutorialdoc'
106+
107+
108+
# -- Options for LaTeX output ---------------------------------------------
109+
110+
latex_elements = {
111+
# The paper size ('letterpaper' or 'a4paper').
112+
#
113+
# 'papersize': 'letterpaper',
114+
115+
# The font size ('10pt', '11pt' or '12pt').
116+
#
117+
# 'pointsize': '10pt',
118+
119+
# Additional stuff for the LaTeX preamble.
120+
#
121+
# 'preamble': '',
122+
123+
# Latex figure (float) alignment
124+
#
125+
# 'figure_align': 'htbp',
126+
}
127+
128+
# Grouping the document tree into LaTeX files. List of tuples
129+
# (source start file, target name, title,
130+
# author, documentclass [howto, manual, or own class]).
131+
latex_documents = [
132+
(master_doc, 'GraphvizTutorial.tex', u'Graphviz Tutorial Documentation',
133+
u'Python Shell', 'manual'),
134+
]
135+
136+
137+
# -- Options for manual page output ---------------------------------------
138+
139+
# One entry per manual page. List of tuples
140+
# (source start file, name, description, authors, manual section).
141+
man_pages = [
142+
(master_doc, 'graphviztutorial', u'Graphviz Tutorial Documentation',
143+
[author], 1)
144+
]
145+
146+
147+
# -- Options for Texinfo output -------------------------------------------
148+
149+
# Grouping the document tree into Texinfo files. List of tuples
150+
# (source start file, target name, title, author,
151+
# dir menu entry, description, category)
152+
texinfo_documents = [
153+
(master_doc, 'GraphvizTutorial', u'Graphviz Tutorial Documentation',
154+
author, 'GraphvizTutorial', 'One line description of project.',
155+
'Miscellaneous'),
156+
]
157+
158+
159+

‎index.rst‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. Graphviz Tutorial documentation master file, created by
2+
sphinx-quickstart on Wed Feb 8 20:16:42 2017.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Graphviz Tutorial 目录
7+
==============================================================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
12+
chap01
13+
14+
15+
索引
16+
==============================================================================
17+
18+
* :ref:`genindex`
19+
* :ref:`modindex`
20+
* :ref:`search`

‎make.bat‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
set SPHINXPROJ=GraphvizTutorial
13+
14+
if "%1" == "" goto help
15+
16+
%SPHINXBUILD% >NUL 2>NUL
17+
if errorlevel 9009 (
18+
echo.
19+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20+
echo.installed, then set the SPHINXBUILD environment variable to point
21+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
22+
echo.may add the Sphinx directory to PATH.
23+
echo.
24+
echo.If you don't have Sphinx installed, grab it from
25+
echo.http://sphinx-doc.org/
26+
exit /b 1
27+
)
28+
29+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30+
goto end
31+
32+
:help
33+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34+
35+
:end
36+
popd

0 commit comments

Comments
 (0)