add sphinx for s2grpah documnet build
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/625341d9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/625341d9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/625341d9 Branch: refs/heads/master Commit: 625341d9f51c45120d948b8bb7431d3472329a1f Parents: d1bf2d1 Author: daewon <dae...@apache.org> Authored: Tue Nov 13 17:15:24 2018 +0900 Committer: daewon <dae...@apache.org> Committed: Tue Nov 13 17:15:24 2018 +0900 ---------------------------------------------------------------------- doc/Makefile | 19 ++ doc/make.bat | 35 ++++ doc/readme.md | 49 +++++ doc/source/conf.py | 186 +++++++++++++++++++ doc/source/getting_started/index.rst | 43 +++++ doc/source/getting_started/your_first_graph.rst | 178 ++++++++++++++++++ doc/source/index.rst | 30 +++ 7 files changed, 540 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/625341d9/doc/Makefile ---------------------------------------------------------------------- diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..69fe55e --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/625341d9/doc/make.bat ---------------------------------------------------------------------- diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 0000000..543c6b1 --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/625341d9/doc/readme.md ---------------------------------------------------------------------- diff --git a/doc/readme.md b/doc/readme.md new file mode 100644 index 0000000..63a2c80 --- /dev/null +++ b/doc/readme.md @@ -0,0 +1,49 @@ +# S2Graph Documentation + +## Dependencies + [Python](https://www.python.org/) + + [Sphinx](http://www.sphinx-doc.org/en/master/) + + [Read the Docs Sphinx Theme](https://sphinx-rtd-theme.readthedocs.io/en/latest/index.html) + +I used [`pip`](https://pip.pypa.io/en/stable/installing/) to install Python module. +I used [`virtualenv`](https://virtualenv.pypa.io/en/latest/) to isolate the Python environment. + +> Depending on your environment, the tools(pip, virtualenv) may not be required + +## Quickstart + +All work is done under the `s2graph/doc` folder. + +``` +cd doc +``` + +### Creating a virtualenv environment for documnet build +``` +pip install virtualenv + +virtualenv -p python s2graph_doc +source s2graph_doc/bin/activate +``` + +### install sphinx and theme +``` +pip install Sphinx +pip install sphinx_rtd_theme +``` + +### Building +``` +make html +``` + +### Viewing +``` +pushd build/html && python -m SimpleHTTPServer 3000 +``` + +### Screenshot + +<img src="https://user-images.githubusercontent.com/1182522/48395569-04995d00-e75b-11e8-87b8-2f28662ef3ca.png"> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/625341d9/doc/source/conf.py ---------------------------------------------------------------------- diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..afa4c10 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,186 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'S2Graph' +copyright = '2018, s2graph' +author = 's2graph' + +# The short X.Y version +version = '' +# The full version, including alpha/beta/rc tags +release = '0.0.2' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.ifconfig', + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# 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 = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'S2Graphdoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'S2Graph.tex', 'S2Graph Documentation', + 's2graph', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 's2graph', 'S2Graph Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'S2Graph', 'S2Graph Documentation', + author, 'S2Graph', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] + + +# -- Extension configuration ------------------------------------------------- + +# -- Options for intersphinx extension --------------------------------------- + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/625341d9/doc/source/getting_started/index.rst ---------------------------------------------------------------------- diff --git a/doc/source/getting_started/index.rst b/doc/source/getting_started/index.rst new file mode 100644 index 0000000..5f54cfc --- /dev/null +++ b/doc/source/getting_started/index.rst @@ -0,0 +1,43 @@ +Getting Started +=============== + +******************** +The Directory Layout +******************** + +Once extracted the downloaded binary release of S2Graph or built from the source as described below, the following files and directories should be found in the directory. + +.. code:: + + DISCLAIMER + LICENCE # the Apache License 2.0 + NOTICE + bin # scripts to manage the lifecycle of S2Graph + conf # configuration files + lib # contains the binary + logs # application logs + var # application data + +***************** +Launching S2Graph +***************** + +The following will launch S2Graph, using HBase in the standalone mode for data storage and H2 as the metadata storage. + +.. code:: + + sh bin/start-s2graph.sh + +To connect to a remote HBase cluster or use MySQL as the metastore, refer to the instructions in ``conf/application.conf`` + +************************ +Building from the Source +************************ + +We use SBT to build the project, which can be installed using Homebrew on MacOS (brew install sbt). For other operating systems, refer to the SBT Tutorial. Once SBT is installed, running the following command on the source root will build the project from the source: + +.. code:: bash + + sbt package + +Depending on the internet connection, the initial run might take a while downloading the required dependencies. Once the build is complete, the same directory layout as in the top of this document can be found at ``target/apache-s2graph-$version-bin``, where ``$version`` is the current version of the project, e.g. ``0.1.0-incubating`` http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/625341d9/doc/source/getting_started/your_first_graph.rst ---------------------------------------------------------------------- diff --git a/doc/source/getting_started/your_first_graph.rst b/doc/source/getting_started/your_first_graph.rst new file mode 100644 index 0000000..72d6e08 --- /dev/null +++ b/doc/source/getting_started/your_first_graph.rst @@ -0,0 +1,178 @@ +Your First S2Graph +================== + +Once the S2Graph server has been set up, you can now start to send HTTP queries to the server to create a graph and pour data in it. This tutorial goes over a simple toy problem to get a sense of how S2Graph's API looks like. For the exact definitions of the terminology used here, refer to The Data Model document. +The toy problem is to create a timeline feature for a simple social media, like a simplified version of Facebook's timeline. Using simple S2Graph queries it is possible to keep track of each user's friends and their posts. + +First, we need a name for the new service. +--------------------------------------------- + +The following POST query will create a service named ``KakaoFavorites`` + +.. code:: bash + + curl -XPOST localhost:9000/graphs/createService -H 'Content-Type: Application/json' -d ' + { + "serviceName": "KakaoFavorites", + "compressionAlgorithm" : "gz" + }' + +To make sure the service is created correctly, check out the following + +.. code:: bash + + curl -XGET localhost:9000/graphs/getService/KakaoFavorites + +Next, we will need some friends. +--------------------------------------------- +In S2Graph, relationships are organized as labels. Create a ``friends`` label with the following ``createLabel`` API call: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/createLabel -H 'Content-Type: Application/json' -d ' + { + "label": "friends", + "srcServiceName": "KakaoFavorites", + "srcColumnName": "userName", + "srcColumnType": "string", + "tgtServiceName": "KakaoFavorites", + "tgtColumnName": "userName", + "tgtColumnType": "string", + "isDirected": "false", + "indices": [], + "props": [], + "consistencyLevel": "strong" + }' + +Check if the label has been created correctly: + +.. code:: bash + + curl -XGET localhost:9000/graphs/getLabel/friends + +Now that the label ``friends`` is ready, we can store the friendship data. Entries of a label are called edges, and you can add edges with ``edges/insert`` API: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/edges/insert -H 'Content-Type: Application/json' -d ' + [ + {"from":"Elmo","to":"Big Bird","label":"friends","props":{},"timestamp":1444360152477}, + {"from":"Elmo","to":"Ernie","label":"friends","props":{},"timestamp":1444360152478}, + {"from":"Elmo","to":"Bert","label":"friends","props":{},"timestamp":1444360152479}, + {"from":"Cookie Monster","to":"Grover","label":"friends","props":{},"timestamp":1444360152480}, + {"from":"Cookie Monster","to":"Kermit","label":"friends","props":{},"timestamp":1444360152481}, + {"from":"Cookie Monster","to":"Oscar","label":"friends","props":{},"timestamp":1444360152482} + ]' + +Query friends of Elmo with ``getEdges`` API: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/getEdges -H 'Content-Type: Application/json' -d ' + { + "srcVertices": [{"serviceName": "KakaoFavorites", "columnName": "userName", "id":"Elmo"}], + "steps": [ + {"step": [{"label": "friends", "direction": "out", "offset": 0, "limit": 10}]} + ] + }' + +Now query friends of Cookie Monster: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/getEdges -H 'Content-Type: Application/json' -d ' + { + "srcVertices": [{"serviceName": "KakaoFavorites", "columnName": "userName", "id":"Cookie Monster"}], + "steps": [ + {"step": [{"label": "friends", "direction": "out", "offset": 0, "limit": 10}]} + ] + }' + +Users of Kakao Favorites will be able to ``post`` URLs of their favorite websites. +---------------------------------------------------------------------------------- + +We will need a new label ``post`` for this data: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/createLabel -H 'Content-Type: Application/json' -d ' + { + "label": "post", + "srcServiceName": "KakaoFavorites", + "srcColumnName": "userName", + "srcColumnType": "string", + "tgtServiceName": "KakaoFavorites", + "tgtColumnName": "url", + "tgtColumnType": "string", + "isDirected": "true", + "indices": [], + "props": [], + "consistencyLevel": "strong" + }' + +Now, insert some posts of the users: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/edges/insert -H 'Content-Type: Application/json' -d ' + [ + {"from":"Big Bird","to":"www.kakaocorp.com/en/main","label":"post","props":{},"timestamp":1444360152477}, + {"from":"Big Bird","to":"github.com/kakao/s2graph","label":"post","props":{},"timestamp":1444360152478}, + {"from":"Ernie","to":"groups.google.com/forum/#!forum/s2graph","label":"post","props":{},"timestamp":1444360152479}, + {"from":"Grover","to":"hbase.apache.org/forum/#!forum/s2graph","label":"post","props":{},"timestamp":1444360152480}, + {"from":"Kermit","to":"www.playframework.com","label":"post","props":{},"timestamp":1444360152481}, + {"from":"Oscar","to":"www.scala-lang.org","label":"post","props":{},"timestamp":1444360152482} + ]' + + +Query posts of Big Bird: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/getEdges -H 'Content-Type: Application/json' -d ' + { + "srcVertices": [{"serviceName": "KakaoFavorites", "columnName": "userName", "id":"Big Bird"}], + "steps": [ + {"step": [{"label": "post", "direction": "out", "offset": 0, "limit": 10}]} + ] + }' + + +So far, we have designed a label schema for the labels ``friends`` and ``post``, and stored some edges to them. +--------------------------------------------------------------------------------------------------------------- + +This should be enough for creating the timeline feature! The following two-step query will return the URLs for Elmo's timeline, which are the posts of Elmo's friends: + + +.. code:: bash + + curl -XPOST localhost:9000/graphs/getEdges -H 'Content-Type: Application/json' -d ' + { + "srcVertices": [{"serviceName": "KakaoFavorites", "columnName": "userName", "id":"Elmo"}], + "steps": [ + {"step": [{"label": "friends", "direction": "out", "offset": 0, "limit": 10}]}, + {"step": [{"label": "post", "direction": "out", "offset": 0, "limit": 10}]} + ] + }' + +Also try Cookie Monster's timeline: + +.. code:: bash + + curl -XPOST localhost:9000/graphs/getEdges -H 'Content-Type: Application/json' -d ' + { + "srcVertices": [{"serviceName": "KakaoFavorites", "columnName": "userName", "id":"Cookie Monster"}], + "steps": [ + {"step": [{"label": "friends", "direction": "out", "offset": 0, "limit": 10}]}, + {"step": [{"label": "post", "direction": "out", "offset": 0, "limit": 10}]} + ] + }' + + +The example above is by no means a full blown social network timeline, but it gives you an idea of how to represent, store and query graph data with S2Graph. + +We also provide a simple script under ``script/test.sh`` so that you can see if everything is setup correctly. + +.. code:: bash + + sh script/test.sh http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/625341d9/doc/source/index.rst ---------------------------------------------------------------------- diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..83bf8d5 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,30 @@ +.. S2Graph documentation master file, created by + sphinx-quickstart on Mon Nov 12 15:53:14 2018. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Introduction +=================================== + +S2Graph is a graph database designed to handle transactional graph processing at scale. Its REST API allows you to store, manage and query relational information using edge and vertex representations in a fully asynchronous and non-blocking manner. This document covers the basic concepts and terminology of S2Graph to help you get a feel for the S2Graph API. + +Mailing Lists +Everyone interested in using and developing S2Graph is welcome to join our mailing lists! + +us...@s2graph.incubator.apache.org is for usage questions and announcements. +d...@s2graph.incubator.apache.org is for people who want to contribute to S2Graph. + +.. toctree:: + :caption: S2Graph Documentation + :maxdepth: 3 + + getting_started/index + getting_started/your_first_graph + +.. + Indices and tables + ================== + + * :ref:`genindex` + * :ref:`modindex` + * :ref:`search`