diff --git a/cgen/__init__.py b/cgen/__init__.py index c5ba3e8e0540c7449398a603ee6f565239e06650..21f5d93065fe37f2796df825adb660d048c26695 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/doc/conf.py b/doc/conf.py index 617058c330a4f25c9d53bde3ac2c264e86bd41af..936661d2477b836766c2ea8c68c86e21514681c4 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,34 +93,24 @@ 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 # ----------------------- -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 = { - '**': [ - '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 +133,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 +169,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 +210,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 +223,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 +234,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://numpy.org/doc/stable/": None, + "https://documen.tician.de/pymbolic/": None, } diff --git a/doc/index.rst b/doc/index.rst index 5ae1b46d7fc18f71b06514245eaa3fd766977d6c..9949fb46e7f019895db7f91dfd86a5396bd5ff53 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -27,6 +27,8 @@ Contents cgen faq + 🚀 Github + 💾 Download Releases Indices and tables ================== diff --git a/setup.cfg b/setup.cfg index b0245a748d8e7418ae511aa3bb235df6579ee048..8fd41a7ba9fd6d38907033f4e9a3cb3efd3ce665 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 b1de365a97a1a687543429066a9e9c0afe0d7902..6df9909a62623c5c0aeb210825fa9fbf5880ed04 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)