Skip to content

Commit

Permalink
#20 add black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kwabenantim committed Mar 20, 2024
1 parent a54a342 commit da5b55d
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 80 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ exclude=
build,
doc,
examples,
docstring-convention=numpy
1 change: 0 additions & 1 deletion cppwg/parsers/source_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# - variable_t (pygccxml.declarations.variable.variable_t)



class CppSourceParser:
"""
Parser for C++ source code
Expand Down
76 changes: 37 additions & 39 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,39 @@
# 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.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
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'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'cppwg'
copyright = u'2017, J. Grogan'
author = u'J. Grogan'
project = "cppwg"
copyright = "2017, J. Grogan"
author = "J. Grogan"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.1'
version = "0.1"
# The full version, including alpha/beta/rc tags.
release = u'0.1.1'
release = "0.1.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -72,10 +74,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

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

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -86,7 +88,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
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
Expand All @@ -97,28 +99,28 @@
# 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']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
"**": [
"about.html",
"navigation.html",
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
"donate.html",
]
}


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

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


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -127,15 +129,12 @@
# 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',
Expand All @@ -145,19 +144,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'cppwg.tex', u'cppwg Documentation',
u'J. Grogan', 'manual'),
(master_doc, "cppwg.tex", "cppwg Documentation", "J. Grogan", "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, 'cppwg', u'cppwg Documentation',
[author], 1)
]
man_pages = [(master_doc, "cppwg", "cppwg Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -166,10 +161,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'cppwg', u'cppwg Documentation',
author, 'cppwg', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"cppwg",
"cppwg Documentation",
author,
"cppwg",
"One line description of project.",
"Miscellaneous",
),
]



2 changes: 1 addition & 1 deletion examples/shapes/src/python/pyshapes/geometry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Bring in everything from the shared module
from pyshapes.geometry._pyshapes_geometry import *
from pyshapes.geometry._pyshapes_geometry import *
2 changes: 1 addition & 1 deletion examples/shapes/src/python/pyshapes/math_funcs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Bring in everything from the shared module
from pyshapes.math_funcs._pyshapes_math_funcs import *
from pyshapes.math_funcs._pyshapes_math_funcs import *
2 changes: 1 addition & 1 deletion examples/shapes/src/python/pyshapes/primitives/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Bring in everything from the shared module
from pyshapes.primitives._pyshapes_primitives import *
from pyshapes.primitives._pyshapes_primitives import *
16 changes: 9 additions & 7 deletions examples/shapes/src/python/test/test_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pyshapes.geometry
import pyshapes.primitives


class TestClasses(unittest.TestCase):

def testGeometry(self):
Expand All @@ -12,13 +13,14 @@ def testGeometry(self):
points = [p1, p2, p3]
triangle = pyshapes.primitives.Shape2()
triangle.SetVertices(points)
self.assertTrue(len(triangle.rGetVertices())==3)
self.assertTrue(len(triangle.rGetVertices()) == 3)

rectangle = pyshapes.primitives.Rectangle(5.0, 10.0)
self.assertTrue(len(rectangle.rGetVertices())==4)
self.assertTrue(len(rectangle.rGetVertices()) == 4)

cuboid = pyshapes.primitives.Cuboid(5.0, 10.0, 20.0)
self.assertTrue(len(cuboid.rGetVertices())==8)
self.assertTrue(len(cuboid.rGetVertices()) == 8)


if __name__ == '__main__':
unittest.main()
if __name__ == "__main__":
unittest.main()
6 changes: 4 additions & 2 deletions examples/shapes/src/python/test/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
from pyshapes import math_funcs


class TestFunctions(unittest.TestCase):

def testAdd(self):
Expand All @@ -9,5 +10,6 @@ def testAdd(self):
c = math_funcs.add(4, 5)
self.assertTrue(c == a + b)

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

if __name__ == "__main__":
unittest.main()
79 changes: 52 additions & 27 deletions examples/shapes/wrapper/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,61 @@
from cppwg import CppWrapperGenerator


def generate_wrapper_code(source_root, wrapper_root, castxml_binary,
package_info_path, includes):

generator = CppWrapperGenerator(source_root,
includes,
wrapper_root,
castxml_binary,
package_info_path)
def generate_wrapper_code(
source_root, wrapper_root, castxml_binary, package_info_path, includes
):

generator = CppWrapperGenerator(
source_root, includes, wrapper_root, castxml_binary, package_info_path
)
generator.generate_wrapper()


if __name__ == "__main__":

parser = ArgumentParser()
parser.add_argument('--source_root', '-s', type=str,
help='Root of the source directory.',
default=os.getcwd())
parser.add_argument('--wrapper_root', '-w', type=str,
help='Root of the wrapper directory.',
default=os.getcwd())
parser.add_argument('--castxml_binary', '-c', type=str,
help='Path to the castxml binary.',
default='castxml')
parser.add_argument('--package_info', '-p', type=str,
help='Path to the package info file.',
default=os.getcwd() + "/package_info.yaml")
parser.add_argument('--includes', '-i', type=str,
help='Path to the includes directory.',
default=os.getcwd())
parser.add_argument(
"--source_root",
"-s",
type=str,
help="Root of the source directory.",
default=os.getcwd(),
)
parser.add_argument(
"--wrapper_root",
"-w",
type=str,
help="Root of the wrapper directory.",
default=os.getcwd(),
)
parser.add_argument(
"--castxml_binary",
"-c",
type=str,
help="Path to the castxml binary.",
default="castxml",
)
parser.add_argument(
"--package_info",
"-p",
type=str,
help="Path to the package info file.",
default=os.getcwd() + "/package_info.yaml",
)
parser.add_argument(
"--includes",
"-i",
type=str,
help="Path to the includes directory.",
default=os.getcwd(),
)
args = parser.parse_args()

all_includes = glob(args.includes + "/*/")
generate_wrapper_code(args.source_root, args.wrapper_root, args.castxml_binary,
args.package_info, all_includes)
generate_wrapper_code(
args.source_root,
args.wrapper_root,
args.castxml_binary,
args.package_info,
all_includes,
)
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ dependencies = ["pyyaml >=6.0", "pygccxml >=2.2", "castxml >=0.4"]
requires-python = ">=3.8"

[project.optional-dependencies]
dev = ["flake8", "flake8-bugbear", "isort"]
dev = ["black", "flake8", "flake8-bugbear", "flake8-docstrings", "isort"]
docs = ["sphinx", "sphinx-rtd-theme", "numpydoc"]

[project.scripts]
cppwg = "cppwg.__main__:main"

[project.urls]
Repository = "https://github.com/Chaste/cppwg/"

[tool.black]
target-version = ["py38", "py39", "py310", "py311", "py312"]

[tool.isort]
profile = "black"

0 comments on commit da5b55d

Please sign in to comment.