From 58a24ea74b284b9beae59a5a75963d2faed292fa Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 1 Dec 2020 18:57:43 -0600 Subject: [PATCH 1/3] Enable, fix flake8 quotes --- cgen/__init__.py | 38 +++++++++++++++++++------------------- setup.cfg | 4 ++++ test/test_cgen.py | 8 ++++---- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/cgen/__init__.py b/cgen/__init__.py index c5ba3e8..21f5d93 100644 --- a/cgen/__init__.py +++ b/cgen/__init__.py @@ -35,7 +35,7 @@ except ImportError: @memoize def is_long_64_bit(): - return _struct.calcsize('l') == 8 + return _struct.calcsize("l") == 8 def dtype_to_ctype(dtype): @@ -197,7 +197,7 @@ class NestedDeclarator(Declarator): class DeclSpecifier(NestedDeclarator): - def __init__(self, subdecl, spec, sep=' '): + def __init__(self, subdecl, spec, sep=" "): NestedDeclarator.__init__(self, subdecl) self.spec = spec self.sep = sep @@ -219,7 +219,7 @@ class DeclSpecifier(NestedDeclarator): class NamespaceQualifier(DeclSpecifier): def __init__(self, namespace, subdecl): - DeclSpecifier.__init__(self, subdecl, namespace, '::') + DeclSpecifier.__init__(self, subdecl, namespace, "::") mapper_method = "map_namespace_qualifier" @@ -257,7 +257,7 @@ class Volatile(NestedDeclarator): class Extern(DeclSpecifier): def __init__(self, language, subdecl): self.language = language - super(Extern, self).__init__(subdecl, "extern \"%s\"" % language) + super(Extern, self).__init__(subdecl, 'extern "%s"' % language) mapper_method = "map_extern" @@ -269,7 +269,7 @@ class TemplateSpecializer(NestedDeclarator): def get_decl_pair(self): sub_tp, sub_decl = self.subdecl.get_decl_pair() - sub_tp[-1] = sub_tp[-1] + '<%s>' % self.specializer + sub_tp[-1] = sub_tp[-1] + "<%s>" % self.specializer return sub_tp, sub_decl mapper_method = "map_template_specializer" @@ -532,7 +532,7 @@ class GenerableStruct(Struct): class Enum(Generable): """An enum-like class for Python that can generate an equivalent C-level - declaration. Does not work within the usual 'declarator' framework + declaration. Does not work within the usual "declarator" framework because it uses macros to define values, and a separate typedef to define the value type. @@ -590,7 +590,7 @@ class Enum(Generable): @classmethod def stringify_value(cls, val): - "Return a string description of the flags set in *val*." + """Return a string description of the flags set in *val*.""" return "|".join( flag_name @@ -773,7 +773,7 @@ class Include(Generable): if self.system: yield "#include <%s>" % self.filename else: - yield "#include \"%s\"" % self.filename + yield '#include "%s"' % self.filename mapper_method = "map_include" @@ -849,11 +849,11 @@ class MultilineComment(Generable): self.skip_space = skip_space def generate(self): - yield '/**' + yield "/**" if self.skip_space is True: - line_begin, comment_end = '*', '*/' + line_begin, comment_end = "*", "*/" else: - line_begin, comment_end = ' * ', ' */' + line_begin, comment_end = " * ", " */" for line in self.text.splitlines(): yield line_begin + line yield comment_end @@ -922,7 +922,7 @@ class InlineInitializer(Initializer): def generate(self): result = super(InlineInitializer, self).generate() for v in result: - if v.endswith(';'): + if v.endswith(";"): yield v[:-1] else: yield v @@ -1067,10 +1067,10 @@ class IfDef(Module): :param elselines: the block of code inside the else [an array of type Generable] """ def __init__(self, condition, iflines, elselines): - ifdef_line = Line('#ifdef %s' % condition) + ifdef_line = Line("#ifdef %s" % condition) if len(elselines): - elselines.insert(0, Line('#else')) - endif_line = Line('#endif') + elselines.insert(0, Line("#else")) + endif_line = Line("#endif") lines = [ifdef_line]+iflines+elselines+[endif_line] super(IfDef, self).__init__(lines) @@ -1086,10 +1086,10 @@ class IfNDef(Module): :param elselines: the block of code inside the else [an array of type Generable] """ def __init__(self, condition, ifndeflines, elselines): - ifndefdef_line = Line('#ifndef %s' % condition) + ifndefdef_line = Line("#ifndef %s" % condition) if len(elselines): - elselines.insert(0, Line('#else')) - lines = [ifndefdef_line]+ifndeflines+elselines+[Line('#endif')] + elselines.insert(0, Line("#else")) + lines = [ifndefdef_line]+ifndeflines+elselines+[Line("#endif")] super(IfNDef, self).__init__(lines) mapper_method = "map_ifndef" @@ -1107,7 +1107,7 @@ class PrivateNamespace(Block): for c in self.contents: for line in c.generate(): - checksum.update(line.encode('utf-8')) + checksum.update(line.encode("utf-8")) return "private_namespace_"+checksum.hexdigest() diff --git a/setup.cfg b/setup.cfg index b0245a7..8fd41a7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,5 +2,9 @@ ignore = E126,E127,E128,E123,E226,E241,E242,E265,E402 max-line-length = 85 +inline-quotes = " +docstring-quotes = """ +multiline-quotes = """ + [easy_install] diff --git a/test/test_cgen.py b/test/test_cgen.py index b1de365..6df9909 100644 --- a/test/test_cgen.py +++ b/test/test_cgen.py @@ -38,10 +38,10 @@ def test_cgen(): #BlankLine(), Comment("all done"), ])) - t_decl = Template('typename T', - FunctionDeclaration(Value('CUdeviceptr', 'scan'), - [Value('CUdeviceptr', 'inputPtr'), - Value('int', 'length')])) + t_decl = Template("typename T", + FunctionDeclaration(Value("CUdeviceptr", "scan"), + [Value("CUdeviceptr", "inputPtr"), + Value("int", "length")])) print(s) print(f_body) -- GitLab From 2e6478d6130e0f5c11e41e5d28d2dc2aa9ac3a23 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 1 Dec 2020 18:58:09 -0600 Subject: [PATCH 2/3] Fix flake8 doc/conf --- doc/conf.py | 77 +++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 617058c..c8e9b73 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -26,31 +26,31 @@ from __future__ import absolute_import # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# coming with Sphinx (named "sphinx.ext.*") or your custom ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - #'sphinx.ext.viewcode' + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + #"sphinx.ext.viewcode" ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8' +#source_encoding = "utf-8" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'cgen' -copyright = u'2011, Andreas Kloeckner' +project = u"cgen" +copyright = u"2011, Andreas Kloeckner" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -58,7 +58,8 @@ copyright = u'2011, Andreas Kloeckner' # # The short X.Y version. ver_dic = {} -exec(compile(open("../cgen/version.py").read(), "../cgen/version.py", 'exec'), ver_dic) +exec(compile(open("../cgen/version.py").read(), "../cgen/version.py", "exec"), + ver_dic) version = ".".join(str(x) for x in ver_dic["VERSION"]) # The full version, including alpha/beta/rc tags. release = ver_dic["VERSION_TEXT"] @@ -75,7 +76,7 @@ release = ver_dic["VERSION_TEXT"] # List of directories, relative to source directory, that shouldn't be searched # for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None @@ -92,7 +93,7 @@ exclude_patterns = ['_build'] #show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # Options for HTML output @@ -108,18 +109,12 @@ html_theme_options = { } html_sidebars = { - '**': [ - 'about.html', - 'navigation.html', - 'relations.html', - 'searchbox.html', - ] } # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. -#html_style = 'default.css' +#html_style = "default.css" # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". @@ -142,7 +137,7 @@ html_sidebars = { # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ['_static'] -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# If not '', a "Last updated on:" timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' @@ -178,23 +173,23 @@ html_sidebars = { #html_file_suffix = '' # Output file base name for HTML help builder. -htmlhelp_basename = 'cgendoc' +htmlhelp_basename = "cgendoc" # Options for LaTeX output # ------------------------ -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' +# The paper size ("letter" or "a4"). +#latex_paper_size = "letter" -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' +# The font size ("10pt", "11pt" or "12pt"). +#latex_font_size = "10pt" # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ - ('index', 'cgen.tex', u'cgen Documentation', - u'Andreas Kloeckner', 'manual'), + ("index", "cgen.tex", u"cgen Documentation", + u"Andreas Kloeckner", "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -219,8 +214,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'cgen', u'cgen Documentation', - [u'Andreas Kloeckner'], 1) + ("index", "cgen", u"cgen Documentation", + [u"Andreas Kloeckner"], 1) ] # If true, show URL addresses after external links. @@ -232,9 +227,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'cgen', u'cgen Documentation', - u'Andreas Kloeckner', 'cgen', 'One line description of project.', - 'Miscellaneous'), + ("index", "cgen", u"cgen Documentation", + u"Andreas Kloeckner", "cgen", "One line description of project.", + "Miscellaneous"), ] # Documents to append as an appendix to all manuals. @@ -243,13 +238,13 @@ texinfo_documents = [ # If false, no module index is generated. #texinfo_domain_indices = True -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# How to display URL addresses: "footnote", "no", or "inline". +#texinfo_show_urls = "footnote" autoclass_content = "both" intersphinx_mapping = { - 'http://docs.python.org/dev': None, - 'http://docs.scipy.org/doc/numpy/': None, - 'http://documen.tician.de/pymbolic/': None, + "https://docs.python.org/3/": None, + "https://docs.scipy.org/doc/numpy/": None, + "https://documen.tician.de/pymbolic/": None, } -- GitLab From 3211272912852ffce62a2a11ac4d4b96fa788bb1 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 1 Dec 2020 18:59:57 -0600 Subject: [PATCH 3/3] Switch to furo doc theme --- doc/conf.py | 10 +++------- doc/index.rst | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index c8e9b73..936661d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -99,17 +99,13 @@ pygments_style = "sphinx" # Options for HTML output # ----------------------- -html_theme = "alabaster" +html_theme = "furo" html_theme_options = { - "extra_nav_links": { - "🚀 Github": "https://github.com/inducer/cgen", - "💾 Download Releases": "https://pypi.python.org/pypi/cgen", - } } html_sidebars = { -} + } # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths @@ -245,6 +241,6 @@ autoclass_content = "both" intersphinx_mapping = { "https://docs.python.org/3/": None, - "https://docs.scipy.org/doc/numpy/": None, + "https://numpy.org/doc/stable/": None, "https://documen.tician.de/pymbolic/": None, } diff --git a/doc/index.rst b/doc/index.rst index 5ae1b46..9949fb4 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -27,6 +27,8 @@ Contents cgen faq + 🚀 Github + 💾 Download Releases Indices and tables ================== -- GitLab