Skip to content

Commit

Permalink
Merge pull request #684 from brave/readthedocs
Browse files Browse the repository at this point in the history
reST, Sphinx, Read The Docs framework
  • Loading branch information
mbacchi committed Oct 2, 2018
2 parents 3e90d97 + cbe3b5c commit 32cab0f
Show file tree
Hide file tree
Showing 11 changed files with 440 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ npm-debug.log
.gclient
.sccache
**.sw[po]
.vscode

# Rendered Sphinx files should be excluded from source control
build
_build

# Clion files
CMakeLists.txt
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = BraveBrowser
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)
36 changes: 36 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=BraveBrowser

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
9 changes: 9 additions & 0 deletions docs/source/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This prevents the code block from having a scroll bar */
pre {
white-space: pre-wrap;
}

/* add padding after logo */
.logo {
padding-bottom: 20px
}
Binary file added docs/source/_static/product_logo_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/product_logo_name_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/source/build-instructions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Brave Build Instructions
************************

Build instructions are hosted in our `GitHub wiki <https://github.com/brave/brave-browser/wiki#build-instructions>`_ at this time.
163 changes: 163 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# -*- 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 = 'Brave Browser'
copyright = '2018, Brave Software'
author = 'Brave Software'

# 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 = [
]

# 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 = ['_build','build',]

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


# -- 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 = 'alabaster'

# 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 = {
'description': 'Next generation Brave browser for macOS, Windows, Linux. <a href="https://www.brave.com">brave.com</a>',
'logo': 'product_logo_name_48.png',
}

# 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 = {}

# html_favicon = "_static/product_logo_32.png"


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'BraveBrowserdoc'


# -- 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, 'BraveBrowser.tex', 'Brave Browser Documentation',
'Brave Software', '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, 'bravebrowser', 'Brave Browser 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, 'BraveBrowser', 'Brave Browser Documentation',
author, 'BraveBrowser', 'One line description of project.',
'Miscellaneous'),
]

def setup(app):
app.add_stylesheet('custom.css')
76 changes: 76 additions & 0 deletions docs/source/docs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
.. _rs_sphinx_readthedocs:

Documentation
*************

We use Sphinx to render, and readthedocs.org to publish, Brave Browser
documentation. You can view the latest documentation at `https://brave-browser.readthedocs.io/en/latest/ <https://brave-browser.readthedocs.io/en/latest/>`_.

Contributing to Brave Browser documentation can be done by editing the
``docs/source/*.rst`` files in the `brave-browser repository <https://github.com/brave/brave-browser>`_
and then opening a PR.



Prerequisites
=============

* Install ``sphinx`` using `these instructions <http://dont-be-afraid-to-commit.readthedocs.io/en/latest/documentation.html#sphinx>`_.
* You might want to create a Python `virtualenv <https://virtualenv.pypa.io/en/stable/>`_ or use `Pipenv <https://docs.pipenv.org/>`_
first to sequester these Python modules from your installed system
modules.


Using Sphinx
============

To create or edit reStructuredText files in the source directory,
`follow this guide <http://dont-be-afraid-to-commit.readthedocs.io/en/latest/documentation.html#using-sphinx-restructuredtext>`_.
The `reStructuredText primer <http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#rst-primer>`_
documents the markup that is supported by Sphinx.

After editing your content, you will render and view the documentation locally.
This is done by running the ``make html`` command from the ``docs`` directory.
Example::

[mbacchi@host docs]$ make html
Running Sphinx v1.7.6
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] docs
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded.

The HTML pages are in build/html.

Now you can view the pages by pointing a web browser at the file
``brave-browser/docs/build/html/index.html``.

After you have verified the documentation looks like you want, you can commit
it and open a PR in GitHub.

ReadTheDocs
===========

We have a project for the `brave-browser repository <https://github.com/brave/brave-browser>`_
already setup on readthedocs.org. You can view the latest documentation at
`https://brave-browser.readthedocs.io/en/latest/ <https://brave-browser.readthedocs.io/en/latest/>`_.

By default, `readthedocs <http://brave-browser.readthedocs.io/>`_
will render any new changes to the documentation
nightly. But readthedocs.org also allows setting up a webhook that will
render new changes to the live site when any commit lands in the repository.
We will setup this webhook when Sphinx and readthedocs.org has
been accepted as the documentation tool of choice by the entire team.
33 changes: 33 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. Copyright (c) 2018 Brave Software
.. _rs_welcome:

Welcome to Brave Docs!
======================

The next generation Brave desktop browser for macOS, Windows, and Linux.

.. _rs_community:

Brave Community Resources
-------------------------
* `community.brave.com <https://community.brave.com/>`_
* :doc:`/docs` process


Contents
--------

.. toctree::
:maxdepth: 2

installing-brave
build-instructions
docs

Indices and tables
------------------

* :ref:`genindex`
* :ref:`search`
Loading

0 comments on commit 32cab0f

Please sign in to comment.