conf.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # 4 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # 5 # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> # 6 # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 7 # Copyright 2018 Morgan Goose <morgan.goose@gmail.com> # 8 # Copyright 2018 Wan Liuyang <tsfdye@gmail.com> # 9 # Copyright 2018 sfdye <tsfdye@gmail.com> # 10 # # 11 # This file is part of PyGithub. # 12 # http://pygithub.readthedocs.io/ # 13 # # 14 # PyGithub is free software: you can redistribute it and/or modify it under # 15 # the terms of the GNU Lesser General Public License as published by the Free # 16 # Software Foundation, either version 3 of the License, or (at your option) # 17 # any later version. # 18 # # 19 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 21 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 22 # details. # 23 # # 24 # You should have received a copy of the GNU Lesser General Public License # 25 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 26 # # 27 ################################################################################ 28 29 import datetime 30 import glob 31 import os 32 import sys 33 34 # If extensions (or modules to document with autodoc) are in another directory, 35 # add these directories to sys.path here. If the directory is relative to the 36 # documentation root, use os.path.abspath to make it absolute, like shown here. 37 sys.path.insert(0, os.path.abspath("..")) 38 from importlib.metadata import version # noqa: E402 39 40 setupVersion = version("pygithub") 41 42 # -- General configuration ----------------------------------------------------- 43 44 # If your documentation needs a minimal Sphinx version, state it here. 45 # needs_sphinx = '1.0' 46 47 # Add any Sphinx extension module names here, as strings. They can be extensions 48 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 49 extensions = ["sphinx.ext.autodoc", "sphinx.ext.coverage", "sphinx.ext.mathjax"] 50 51 # Add any paths that contain templates here, relative to this directory. 52 templates_path = ["_templates"] 53 54 # The suffix of source filenames. 55 source_suffix = ".rst" 56 57 # The encoding of source files. 58 # source_encoding = 'utf-8-sig' 59 60 # The master toctree document. 61 master_doc = "index" 62 63 # General information about the project. 64 project = "PyGithub" 65 copyright = "%d, Vincent Jacques" % datetime.date.today().year 66 67 # The version info for the project you're documenting, acts as replacement for 68 # |version| and |release|, also used in various other places throughout the 69 # built documents. 70 # 71 # The short X.Y version. 72 version = setupVersion 73 # The full version, including alpha/beta/rc tags. 74 release = setupVersion 75 76 # The language for content autogenerated by Sphinx. Refer to documentation 77 # for a list of supported languages. 78 # language = None 79 80 # There are two options for replacing |today|: either, you set today to some 81 # non-false value, then it is used: 82 # today = '' 83 # Else, today_fmt is used as the format for a strftime call. 84 # today_fmt = '%B %d, %Y' 85 86 # List of patterns, relative to source directory, that match files and 87 # directories to ignore when looking for source files. 88 exclude_patterns = [] 89 90 # The reST default role (used for this markup: `text`) to use for all documents. 91 # default_role = None 92 93 # If true, '()' will be appended to :func: etc. cross-reference text. 94 # add_function_parentheses = True 95 96 # If true, the current module name will be prepended to all description 97 # unit titles (such as .. function::). 98 # add_module_names = True 99 100 # If true, sectionauthor and moduleauthor directives will be shown in the 101 # output. They are ignored by default. 102 # show_authors = False 103 104 # The name of the Pygments (syntax highlighting) style to use. 105 pygments_style = "sphinx" 106 107 # A list of ignored prefixes for module index sorting. 108 # modindex_common_prefix = [] 109 110 111 # -- Options for HTML output --------------------------------------------------- 112 113 # The theme to use for HTML and HTML Help pages. See the documentation for 114 # a list of builtin themes. 115 html_theme = "sphinx_rtd_theme" 116 117 # Theme options are theme-specific and customize the look and feel of a theme 118 # further. For a list of options available for each theme, see the 119 # documentation. 120 # html_theme_options = {} 121 122 # Add any paths that contain custom themes here, relative to this directory. 123 # html_theme_path = [] 124 125 # The name for this set of Sphinx documents. If None, it defaults to 126 # "<project> v<release> documentation". 127 # html_title = None 128 129 # A shorter title for the navigation bar. Default is the same as html_title. 130 # html_short_title = None 131 132 # The name of an image file (relative to this directory) to place at the top 133 # of the sidebar. 134 # html_logo = None 135 136 # The name of an image file (within the static path) to use as favicon of the 137 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 138 # pixels large. 139 # html_favicon = None 140 141 # Add any paths that contain custom static files (such as style sheets) here, 142 # relative to this directory. They are copied after the builtin static files, 143 # so a file named "default.css" will overwrite the builtin "default.css". 144 html_static_path = ["_static"] 145 146 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 147 # using the given strftime format. 148 # html_last_updated_fmt = '%b %d, %Y' 149 150 # If true, SmartyPants will be used to convert quotes and dashes to 151 # typographically correct entities. 152 # html_use_smartypants = True 153 154 # Custom sidebar templates, maps document names to template names. 155 # html_sidebars = {} 156 157 # Additional templates that should be rendered to pages, maps page names to 158 # template names. 159 # html_additional_pages = {} 160 161 # If false, no module index is generated. 162 # html_domain_indices = True 163 164 # If false, no index is generated. 165 # html_use_index = True 166 167 # If true, the index is split into individual pages for each letter. 168 # html_split_index = False 169 170 # If true, links to the reST sources are added to the pages. 171 # html_show_sourcelink = True 172 173 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 174 # html_show_sphinx = True 175 176 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 177 # html_show_copyright = True 178 179 # If true, an OpenSearch description file will be output, and all pages will 180 # contain a <link> tag referring to it. The value of this option must be the 181 # base URL from which the finished HTML is served. 182 # html_use_opensearch = '' 183 184 # This is the file name suffix for HTML files (e.g. ".xhtml"). 185 # html_file_suffix = None 186 187 # Output file base name for HTML help builder. 188 htmlhelp_basename = "PyGithubdoc" 189 190 191 # -- Options for LaTeX output -------------------------------------------------- 192 193 # latex_elements = { 194 # The paper size ('letterpaper' or 'a4paper'). 195 # 'papersize': 'letterpaper', 196 197 # The font size ('10pt', '11pt' or '12pt'). 198 # 'pointsize': '10pt', 199 200 # Additional stuff for the LaTeX preamble. 201 # 'preamble': '', 202 # } 203 204 # Grouping the document tree into LaTeX files. List of tuples 205 # (source start file, target name, title, author, documentclass [howto/manual]). 206 latex_documents = [ 207 ("index", "PyGithub.tex", "PyGithub Documentation", "Vincent Jacques", "manual"), 208 ] 209 210 # The name of an image file (relative to this directory) to place at the top of 211 # the title page. 212 # latex_logo = None 213 214 # For "manual" documents, if this is true, then toplevel headings are parts, 215 # not chapters. 216 # latex_use_parts = False 217 218 # If true, show page references after internal links. 219 # latex_show_pagerefs = False 220 221 # If true, show URL addresses after external links. 222 # latex_show_urls = False 223 224 # Documents to append as an appendix to all manuals. 225 # latex_appendices = [] 226 227 # If false, no module index is generated. 228 # latex_domain_indices = True 229 230 231 # -- Options for manual page output -------------------------------------------- 232 233 # One entry per manual page. List of tuples 234 # (source start file, name, description, authors, manual section). 235 man_pages = [("index", "pygithub", "PyGithub Documentation", ["Vincent Jacques"], 1)] 236 237 # If true, show URL addresses after external links. 238 # man_show_urls = False 239 240 241 # -- Options for Texinfo output ------------------------------------------------ 242 243 # Grouping the document tree into Texinfo files. List of tuples 244 # (source start file, target name, title, author, 245 # dir menu entry, description, category) 246 texinfo_documents = [ 247 ( 248 "index", 249 "PyGithub", 250 "PyGithub Documentation", 251 "Vincent Jacques", 252 "PyGithub", 253 "One line description of project.", 254 "Miscellaneous", 255 ), 256 ] 257 258 # Documents to append as an appendix to all manuals. 259 # texinfo_appendices = [] 260 261 # If false, no module index is generated. 262 # texinfo_domain_indices = True 263 264 # How to display URL addresses: 'footnote', 'no', or 'inline'. 265 # texinfo_show_urls = 'footnote' 266 267 autodoc_default_flags = ["members"] 268 autodoc_member_order = "bysource" 269 autoclass_content = "both" 270 271 githubClasses = [ 272 fileName[10:-3] 273 for fileName in sorted(glob.glob("../github/*.py")) 274 if fileName 275 not in [ 276 "../github/GithubException.py", 277 "../github/GithubObject.py", 278 "../github/InputFileContent.py", 279 "../github/InputGitAuthor.py", 280 "../github/InputGitTreeElement.py", 281 "../github/Legacy.py", 282 "../github/MainClass.py", 283 "../github/PaginatedList.py", 284 "../github/Requester.py", 285 "../github/Consts.py", 286 "../github/__init__.py", 287 ] 288 ] 289 290 with open("github_objects.rst", "w") as f: 291 f.write("Github objects\n") 292 f.write("==============\n") 293 f.write("\n") 294 f.write(".. autoclass:: github.GithubObject.GithubObject()\n") 295 f.write("\n") 296 f.write(".. toctree::\n") 297 for githubClass in githubClasses: 298 f.write(" github_objects/" + githubClass + "\n") 299 300 for githubClass in githubClasses: 301 with open("github_objects/" + githubClass + ".rst", "w") as f: 302 f.write(githubClass + "\n") 303 f.write("=" * len(githubClass) + "\n") 304 f.write("\n") 305 f.write(".. autoclass:: github." + githubClass + "." + githubClass + "()\n") 306 307 methods = dict() 308 for githubClass in githubClasses + ["MainClass"]: 309 with open("../github/" + githubClass + ".py") as f: 310 if githubClass == "MainClass": 311 githubClass = "github.MainClass.Github" 312 else: 313 githubClass = "github." + githubClass + "." + githubClass 314 method = None 315 isProperty = False 316 for line in f: 317 line = line.rstrip() 318 if line == " @property": 319 isProperty = True 320 if line.startswith(" def "): 321 if not isProperty: 322 method = line.split("(")[0][8:] 323 if method in [ 324 "_initAttributes", 325 "_useAttributes", 326 "__init__", 327 "__create_pull_1", 328 "__create_pull_2", 329 "__create_pull", 330 "_hub", 331 "__get_FIX_REPO_GET_GIT_REF", 332 "__set_FIX_REPO_GET_GIT_REF", 333 "__get_per_page", 334 "__set_per_page", 335 "create_from_raw_data", 336 "dump", 337 "load", 338 ]: 339 method = None 340 isProperty = False 341 if line.startswith(" :calls: `"): 342 for callee in line[16:].split(" or "): 343 verb, url = callee[1:].split(" ")[0:2] 344 if url not in methods: 345 methods[url] = dict() 346 if verb not in methods[url]: 347 methods[url][verb] = set() 348 methods[url][verb].add(":meth:`" + githubClass + "." + method + "`") 349 method = None 350 351 methods["/markdown/raw"] = dict() 352 methods["/markdown/raw"]["POST"] = ["Not implemented, see ``/markdown``"] 353 methods["/rate_limit"] = dict() 354 methods["/rate_limit"]["GET"] = ["Not implemented, see `Github.rate_limiting`"] 355 356 with open("apis.rst", "w") as apis: 357 apis.write("APIs\n") 358 apis.write("====\n") 359 apis.write("\n") 360 for url, verbs in sorted(methods.items()): 361 apis.write("* ``" + url + "``\n") 362 apis.write("\n") 363 for verb in ["GET", "PATCH", "POST", "PUT", "DELETE"]: 364 if verb in verbs: 365 apis.write(" * " + verb + ": " + " or ".join(sorted(verbs[verb])) + "\n") 366 apis.write("\n")