Skip to content

Commit

Permalink
Add build date and versioning to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
olagrottvik committed Feb 4, 2020
1 parent 5975995 commit 1feae58
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[bumpversion]
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))?(\-(?P<release>[a-z]+))?
serialize =
serialize =
{major}.{minor}.{patch}-{release}
{major}.{minor}.{patch}
{major}.{minor}
Expand All @@ -10,11 +10,11 @@ tag = True

[bumpversion:file:setup.py]

[bumpversion:file:bust/__main__.py]
[bumpversion:file:bust/_version.py]

[bumpversion:part:release]
optional_value = gamma
values =
values =
dev
gamma

3 changes: 1 addition & 2 deletions bust/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
from bust.testbench import Testbench
from bust.generation import generate_output
from bust.exceptions import FormatError, InvalidAddress, InvalidRegister, InvalidBusType, InvalidResetMode

__VERSION__ = '0.8.0-dev'
from bust._version import __VERSION__


def main():
Expand Down
1 change: 1 addition & 0 deletions bust/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__VERSION__ = '0.8.0-dev'
23 changes: 18 additions & 5 deletions bust/documentation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pylatexenc.latexencode import utf8tolatex
from bust.utils import indent_string
from bust._version import __VERSION__


class Documentation(object):
Expand All @@ -10,16 +11,26 @@ class Documentation(object):
def __init__(self, module):
self.module = module

def return_tex_documentation(self):
def return_tex_documentation(self, test_version=None):
if test_version is None:
version = __VERSION__
else:
version = test_version
s = tex_top
s += "\n\n"
s += r"\title{" + utf8tolatex(self.module.name) + "}\n"
s += r"\author{}" + "\n"
s += r"\date{}" + "\n"
s += "\n"
s += r"\begin{document}" + "\n"
s += r"\author{" + self.module.get_version() + "}\n"
s += r"\date{\today\ \currenttime}" + "\n"
s += "\n"
s += r"\pagestyle{fancy}" + "\n"
s += r"\fancyhf{}" + "\n"
s += r"\fancyhead[C]{Generated by bust " + version + "}\n"
s += r"\fancyfoot[L]{\today\ \currenttime}" + "\n"
s += r"\fancyfoot[C]{\thepage}" + "\n"
s += r"\fancyfoot[R]{" + self.module.get_version() + "}\n\n\n"
s += r"\begin{document}" + "\n\n"
s += r"\maketitle" + "\n"
s += r"\thispagestyle{fancy}" + "\n"
s += "\n"

s += utf8tolatex(self.module.description) + "\n\n"
Expand Down Expand Up @@ -109,6 +120,8 @@ def return_tex_documentation(self):


tex_top = r"""\documentclass{article}
\usepackage{fancyhdr}
\usepackage{datetime}
\usepackage[margin=1in]{geometry}
\usepackage{register}
\usepackage{enumitem}
Expand Down
13 changes: 11 additions & 2 deletions bust/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ def __init__(self, mod, bus, settings):
self.name = mod['name']
self.description = mod['description']
self.description_with_breaks = add_line_breaks(mod['description'], 25)
self.version = None
self.git_hash = None
if 'version' in mod:
self.version = mod['version']
else:
self.version = None
self.git_hash = None # not used

self.addr_width = bus.addr_width
self.data_width = bus.data_width
Expand All @@ -60,6 +63,12 @@ def __init__(self, mod, bus, settings):
print(e)
exit(2)

def get_version(self):
if self.version is None:
return ""
else:
return "Version: {}".format(self.version)

def add_register(self, reg):
if self.register_valid(reg):
if "address" in reg:
Expand Down
1 change: 1 addition & 0 deletions example/example_axi.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"module": {
"name": "example_axi",
"version": "1.0",
"description": "An example module that contain all the register types that are currently supported by bust.",
"register": [
{
Expand Down
Binary file added example/example_axi/doc/example_axi.pdf
Binary file not shown.
15 changes: 13 additions & 2 deletions example/example_axi/doc/example_axi.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{datetime}
\usepackage[margin=1in]{geometry}
\usepackage{register}
\usepackage{enumitem}
Expand All @@ -21,12 +23,21 @@
}

\title{example{\_}axi}
\author{}
\date{}
\author{Version: 1.0}
\date{\today\ \currenttime}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{Generated by bust v0.8}
\fancyfoot[L]{\today\ \currenttime}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{Version: 1.0}


\begin{document}

\maketitle
\thispagestyle{fancy}

An example module that contain all the register types that are currently supported by bust.

Expand Down
1 change: 1 addition & 0 deletions example/example_ipbus.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"module": {
"name": "example_ipbus",
"version": "1.0",
"description": "An example module that contain all the register types that are currently supported by bust.",
"register": [
{
Expand Down
15 changes: 13 additions & 2 deletions example/example_ipbus/doc/example_ipbus.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{datetime}
\usepackage[margin=1in]{geometry}
\usepackage{register}
\usepackage{enumitem}
Expand All @@ -21,12 +23,21 @@
}

\title{example{\_}ipbus}
\author{}
\date{}
\author{Version: 1.0}
\date{\today\ \currenttime}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{Generated by bust v0.8}
\fancyfoot[L]{\today\ \currenttime}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{Version: 1.0}


\begin{document}

\maketitle
\thispagestyle{fancy}

An example module that contain all the register types that are currently supported by bust.

Expand Down
2 changes: 1 addition & 1 deletion tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_doc(self):
self.logger.info("Testing Doc generation...")
with open('example/example_{0}/doc/example_{0}.tex'.format(holder.bus.bus_type)) as f:
string = f.read()
self.assertEqual(holder.doc.return_tex_documentation(), string, "doc must match manual file")
self.assertEqual(holder.doc.return_tex_documentation("v0.8"), string, "doc must match manual file")

if __name__ == '__main__':
unittest.main()

0 comments on commit 1feae58

Please sign in to comment.