From 51e068f4eae0d9a09e8308069f34d4a7d00fa25a Mon Sep 17 00:00:00 2001 From: Geoffrey Hunter Date: Wed, 29 May 2019 22:15:19 -0700 Subject: [PATCH] - Added Sphinx documentation. --- .gitignore | 5 ++++- CHANGELOG.md | 4 ++++ docs/Makefile | 19 +++++++++++++++++++ docs/conf.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 29 +++++++++++++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++++ test/unit/TestUtil.hpp | 12 +++++++----- 7 files changed, 153 insertions(+), 6 deletions(-) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/.gitignore b/.gitignore index 7028873..1fc2c47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ build/ cmake-build-debug/ .idea/workspace.xml -.vscode/c_cpp_properties.json \ No newline at end of file +.vscode/ + +# Sphinx build dir +docs/_build/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4de23bc..0ea7204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) @@ -6,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added +- Sphinx documentation. + ## [v2.0.1] - 2017-11-27 ### Fixed diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..298ea9e --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,19 @@ +# 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) + +.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 diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..7371f8c --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,55 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains 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 = 'CppLinuxSerial' +copyright = '2019, Geoffrey Hunter' +author = 'Geoffrey Hunter' + +# The full version, including alpha/beta/rc tags +release = 'v1.0.0' + + +# -- General configuration --------------------------------------------------- + +# 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'] + +# 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'] + + +# -- 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' + +# 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'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..0005406 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,29 @@ +.. CppLinuxSerial documentation master file, created by + sphinx-quickstart on Wed May 29 22:11:17 2019. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to CppLinuxSerial's documentation! +========================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + +Building +======== + +``` +mkdir build +cd build/ +cmake .. +make +``` + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..27f573b --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +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 diff --git a/test/unit/TestUtil.hpp b/test/unit/TestUtil.hpp index 1cf1a34..a00e8a1 100644 --- a/test/unit/TestUtil.hpp +++ b/test/unit/TestUtil.hpp @@ -55,13 +55,15 @@ namespace mn { void CreateVirtualSerialPortPair() { std::cout << "Creating virtual serial port pair..." << std::endl; - std::system("nohup sudo socat -d -d pty,raw,echo=0,link=/dev/ttyS10 pty,raw,echo=0,link=/dev/ttyS11 &"); + std::system((std::string("nohup sudo socat -d -d pty,raw,echo=0,link=") + + device0Name_ + " pty,raw,echo=0,link=" + + device1Name_ + " &").c_str()); // Hacky! Since socat is detached, we have no idea at what point it has created // ttyS10 and ttyS11. Assume 1 second is long enough... std::this_thread::sleep_for(1s); - std::system("sudo chmod a+rw /dev/ttyS10"); - std::system("sudo chmod a+rw /dev/ttyS11"); + std::system((std::string("sudo chmod a+rw ") + GetDevice0Name()).c_str()); + std::system((std::string("sudo chmod a+rw ") + GetDevice1Name()).c_str()); } void CloseSerialPorts() { @@ -78,8 +80,8 @@ namespace mn { return device1Name_; } - std::string device0Name_ = "/dev/ttyS10"; - std::string device1Name_ = "/dev/ttyS11"; + std::string device0Name_ = "/dev/ttyS31"; + std::string device1Name_ = "/dev/ttyS32"; protected: -- libgit2 0.21.4