Skip to content

Commit

Permalink
[Doc] Add Documentation/ stub
Browse files Browse the repository at this point in the history
  • Loading branch information
woju committed Aug 21, 2019
1 parent 24cba75 commit 3928126
Show file tree
Hide file tree
Showing 15 changed files with 601 additions and 219 deletions.
1 change: 1 addition & 0 deletions Documentation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_build
26 changes: 26 additions & 0 deletions Documentation/Doxyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
PROJECT_NAME = "Graphene"
OUTPUT_DIRECTORY = _build/doxygen

GENERATE_XML = YES
XML_PROGRAMLISTING = NO
XML_OUTPUT = xml

GENERATE_HTML = NO
GENERATE_LATEX = NO

RECURSIVE = YES
INPUT = \
../Pal \
../LibOS/shim/include \
../LibOS/shim/src

EXCLUDE = \
../Pal/lib \
../Pal/regression \
../Pal/test
#EXCLUDE_PATTERNS =

WARN_NO_PARAMDOC = YES
WARN_AS_ERROR = NO
OPTIMIZE_OUTPUT_FOR_C = YES
EXTRACT_STATIC = YES
22 changes: 22 additions & 0 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

clean:
$(RM) -r "$(BUILDDIR)"

.PHONY: help Makefile Doxyfile clean

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile Doxyfile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Empty file added Documentation/_static/.gitigore
Empty file.
Empty file.
139 changes: 139 additions & 0 deletions Documentation/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# -*- 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('.'))

import collections
import pathlib
import subprocess

import recommonmark.parser

# -- Project information -----------------------------------------------------

project = 'Graphene'
copyright = '2019, Graphene Contributors'
author = 'Graphene Contributors'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = ''


# -- 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.todo',
'breathe',
'recommonmark',
'sphinx_rtd_theme',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
'.markdown': 'markdown',
}

# 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 = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None

rst_prolog = '''
.. |nbsp| unicode:: 0xa0
:trim:
'''

breathe_default_project = 'graphene'
breathe_projects = {breathe_default_project: '_build/doxygen/xml'}

def generate_doxygen(app):
subprocess.check_call(['doxygen', 'Doxyfile'])
def setup(app):
app.connect('builder-inited', generate_doxygen)

todo_include_todos = True

# -- 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 manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('manpages/pal_loader', 'pal_loader', 'FIXME Loader', [author], 1),
]

# barf if a page is not included
assert (collections.Counter(str(p.with_suffix(''))
for p in pathlib.Path().glob('manpages/*.rst')
if not p.stem == 'index')
== collections.Counter(source
for source, *_ in man_pages))
15 changes: 15 additions & 0 deletions Documentation/glossary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Glossary
========

.. keep this file sorted lexicographically
.. glossary::

PAL
Platform Adaption Layer

.. todo:: Is this really correct?

SGX
Software Guard Extensions is a set of instructions on Intel processors.
See https://en.wikipedia.org/wiki/Software_Guard_Extensions.
47 changes: 47 additions & 0 deletions Documentation/howto-doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.. _doc-howto:

How to write documentation
==========================

Documentation is generally written as `reStructuredText`_ files and processed
using `Sphinx`_. See `Sphinx' reST primer`_ for short introduction into syntax.
:ref:`Old Wiki <old-wiki>` is imported as it was, in Markdown, but new
documentation should be written in reST.

API documentation of C |nbsp| language should be written as Doxygen comments
(prefer Qt-style ``/*!`` and ``\param``) and then included in one of the
``.rst`` files (with appropriate description) using one of the `Breathe
directives`_, like :rst:dir:`doxygenfunction` or :rst:dir:`doxygenstruct`. See
`Breathe`_ documentation for more info. Do not use ``autodoxygen`` directives,
and especially do not use ``.. doxygenfile::``, because documentation should be
written as prose, not a |nbsp| coredump.

In ``.rst`` files use 3-space tab. This is an uncommon value, but good value
because intended blocks usually follow explicit markup, which begins with
``..``). Wrap the paragraphs at 80th character, but don't wrap verbatim text
like logs and use applicable style when wrapping code examples. Use Python
convention for header hierarchy: ``#`` with overline, ``*`` with overline,
``=``, ``-``, ``^``, ``"``. This means most documents use only ``=`` and ``-``
underlines. Those underlines are easy to enter in :command:`vim` using the
combination ``yypVr-``.

Documentation of the code should be organized into files by logical concepts,
as they fit into programmers mind. Ideally, this should match the source files,
if those files were organised correctly in the first place, but the reality may
be different. In case of doubt, place them as they fit the narration of the
document, not as they are placed in the source files.

Documents should be grouped by general areas and presented using
:rst:dir:`toctree` directive in :file:`index.rst` file. This causes them to be
included in TOC in the main document and also in sidebar on RTD.

The documentation targets ``html`` output of Sphinx. The :file:`manpages/`
subdirectory also targets ``manpage`` builder. Other formats (like ``latex``)
may be considered in the future, but for now their output is neither published
not cared for.

.. _reStructuredText: https://en.wikipedia.org/wiki/ReStructuredText
.. _Sphinx: https://www.sphinx-doc.org/
.. _Sphinx' reST primer: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
.. _Breathe: https://breathe.readthedocs.io/en/latest/
.. _Breathe directives: https://breathe.readthedocs.io/en/latest/directives.html
36 changes: 36 additions & 0 deletions Documentation/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. include:: ../README.rst

.. toctree::
:caption: Introduction
:maxdepth: 2

glossary
howto-doc

.. toctree::
:caption: LibOS

libos/shim-init

.. toctree::
:caption: Manual pages
:maxdepth: 1
:glob:

manpages/*

.. _old-wiki:

.. toctree::
:caption: Old Wiki (to be rewritten)
:maxdepth: 1
:glob:

oldwiki/*

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
10 changes: 10 additions & 0 deletions Documentation/libos/shim-init.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
A random file documentation
===========================

.. note::

This file is more like a |nbsp| stub, not yet a |nbsp| real documentation.

There is a |nbsp| random function:

.. doxygenfunction:: parse_int
42 changes: 42 additions & 0 deletions Documentation/manpages/pal_loader.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. program:: pal_loader

======================================
:program:`pal_loader` -- Run something
======================================

.. note::

This page is a stub.

Synopsis
========

:command:`pal_loader` [SGX] [GDB] {<*MANIFEST*> | <*EXECUTABLE*>} [<*ARGS*> ...]

Description
===========

Command line arguments
======================

.. option:: SGX

Enable :term:`SGX`.

.. seealso::

:envvar:`SGX environment variable <SGX>`
For an equivalent.

Environment variables
=====================

.. envvar:: SGX

If not empty and not ``0``, enable :term:`SGX`. Could be used instead of
:option:`SGX option <SGX>`. This has some unexplained interaction with
:envvar:`SGX_RUN`.

.. envvar:: SGX_RUN

This is a mystery to me. It cannot be set together with :envvar:`SGX`.
2 changes: 2 additions & 0 deletions Documentation/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
breathe
recommonmark
13 changes: 11 additions & 2 deletions LibOS/shim/src/shim_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

/*
* shim_init.c
/*!
* \file shim_init.c
*
* This file contains entry and exit functions of library OS.
*/
Expand Down Expand Up @@ -110,6 +110,15 @@ long convert_pal_errno (long err)
pal_errno_to_unix_errno[err] : 0;
}

/*!
* \brief Parse a number into an unsigned long.
*
* \param str A string containing a non-negative number.
*
* By default the number should be decimal, but if it starts with 0x it is
* parsed as hexadecimal and if it otherwise starts with 0, it is parsed as
* octal.
*/
unsigned long parse_int (const char * str)
{
unsigned long num = 0;
Expand Down
Loading

0 comments on commit 3928126

Please sign in to comment.