From 8cef79142f61af13e7ae0a523e958b45f1bd6299 Mon Sep 17 00:00:00 2001 From: Robert Clarke Date: Wed, 8 Feb 2023 13:59:02 -0500 Subject: Beginning of initial draft --- docs/.gitignore | 3 ++ docs/README.md | 8 ++++ docs/makefile | 7 ++++ docs/styleguide-cpp.pdf | Bin 0 -> 40093 bytes docs/styleguide-cpp.tex | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 docs/.gitignore create mode 100644 docs/README.md create mode 100644 docs/makefile create mode 100644 docs/styleguide-cpp.pdf create mode 100644 docs/styleguide-cpp.tex (limited to 'docs') diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..6e25999 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,3 @@ +*.aux +*.log +*.toc \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..0ba61fc --- /dev/null +++ b/docs/README.md @@ -0,0 +1,8 @@ +# Documentation + +Documentation files have been written in [LaTeX](https://en.wikipedia.org/wiki/LaTeX). If you would like to generate these files yourself, please install these packages or equivalent for your distribution: + +```shell +sudo apt install -y texlive-latex-recommended +sudo apt install -y texlive-latex-extra +``` \ No newline at end of file diff --git a/docs/makefile b/docs/makefile new file mode 100644 index 0000000..f5aeba8 --- /dev/null +++ b/docs/makefile @@ -0,0 +1,7 @@ +TARGET=styleguide-cpp.tex + +docs: $(TARGET) + latex -output-format=pdf $(TARGET) + +clean: + rm -f *.aux *.dvi *.log *.out *.toc \ No newline at end of file diff --git a/docs/styleguide-cpp.pdf b/docs/styleguide-cpp.pdf new file mode 100644 index 0000000..bc58daf Binary files /dev/null and b/docs/styleguide-cpp.pdf differ diff --git a/docs/styleguide-cpp.tex b/docs/styleguide-cpp.tex new file mode 100644 index 0000000..c606d37 --- /dev/null +++ b/docs/styleguide-cpp.tex @@ -0,0 +1,100 @@ +\documentclass{article} +\usepackage[colorlinks = true, urlcolor = blue, linkcolor = blue]{hyperref} +\usepackage{multirow} + + +%Setup for code snippets +\usepackage{listings} +\usepackage{xcolor} +\definecolor{darkGreen}{RGB}{63,127,95} +\lstset { + language=C++, + backgroundcolor=\color{black!3}, + basicstyle=\footnotesize, + basicstyle=\ttfamily, + keywordstyle=\color{blue}\ttfamily, + stringstyle=\color{red}\ttfamily, + commentstyle=\color{darkGreen}\ttfamily, + morecomment=[l][\color{magenta}]{\#} +} + +\usepackage{helvet} +\renewcommand{\rmdefault}{\sfdefault} %Use sans-serif font family + + +\title{OpenVic2 C++ Style Guidelines (Draft)} +\author{ZincLadder} +\date{\today\\v0.0.1} + + + + +\begin{document} +%===================================== + +\maketitle +\tableofcontents +\clearpage + +\section{Why Style?} +You may be wondering "Why do we need a style guide?" "Are you trying to give me homework?" + +\subsection{General Principles} +\begin{itemize} + \item Prefer clarity over brevity + \item Don't optimize prematurely + \item Avoid C-style casts +\end{itemize} + +\subsection{File Formatting} +Source code files should adhere to the following: +\begin{itemize} + \item Encoded in UTF-8 + \item Use tabs for indentation + \item Use LF for end-of-line sequences + \item Not have any trailing whitespace (Lines which end in spaces or tabs) + \item Any \#include directives should be at the top of the file +\end{itemize} + + +\section{Conventions} +\subsection{Naming Conventions} + +\begin{table}[!ht] + \begin{center} + \caption{Basic Naming Conventions} + \begin{tabular}{|l|l|l|} + \hline + \bf Item & \bf Writing Convention & \bf Example \\ + \hline + Class and Struct Names & PascalCase & MyCoolExample \\ + Variables and Function Names & CamelCase & myCoolExample \\ + Constants, Enum Values, and Preprocessor & SnakeCase (all-caps) & MY\_COOL\_EXAMPLE \\ + Type aliases & SnakeCase (lower) & my\_cool\_example\_t \\ + \hline + \end{tabular} + \end{center} +\end{table} + +\begin{lstlisting} +#pragma once +#include +#include +// A comment +constexpr size_t UNIQUE_RGB_COLOURS = 256 * 256 * 256; + +struct RGBColour { + unsigned char r; + unsigned char g; + unsigned char b; +}; + +bool isColourGreyscale(RGBColour c); + +class Something { + +}; +\end{lstlisting} + +%===================================== +\end{document} -- cgit v1.2.3-56-ga3b1