nltk documentation build configuration file sphinxquickstart on wed nov 2 17 02 59 2011 this file is execfiled with the current directory set to its containing dir note that not all possible configuration values are present in this autogenerated file all configuration values have a default values that are commented out serve to show the default if extensions or modules to document with autodoc are in another directory add these directories to sys path here if the directory is relative to the documentation root use os path abspath to make it absolute like shown here build docs using nltk from the upper dir not the installed version general configuration if your documentation needs a minimal sphinx version state it here needssphinx 2 2 add any sphinx extension module names here as strings they can be extensions coming with sphinx named sphinx ext or your custom ones generating contents in the howto folder based on the ntlktest doctest files as well as contents in the team folder based on team json load jinja template iterate over doctest files and find the modulename ignore index doctest we already have an index i e howto rst write rst files based on the doctesttemplate load the team json data load the team jinja template build the team howto page before creating the sphinx build add any paths that contain templates here relative to this directory the suffix of source filenames the encoding of source files sourceencoding utf8sig the master toctree document general information about the project 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 the full version including alphabetarc tags the language for content autogenerated by sphinx refer to documentation for a list of supported languages language none there are two options for replacing today either you set today to some nonfalse value then it is used today else todayfmt is used as the format for a strftime call todayfmt b d y list of patterns relative to source directory that match files and directories to ignore when looking for source files the rest default role used for this markup text to use for all documents defaultrole none if true will be appended to func etc crossreference text addfunctionparentheses true if true the current module name will be prepended to all description unit titles such as function addmodulenames true if true section and module directives will be shown in the output they are ignored by default shows false the name of the pygments syntax highlighting style to use a list of ignored prefixes for module index sorting options for html output the theme to use for html and html help pages see the documentation for a list of builtin themes theme options are themespecific and customize the look and feel of a theme further for a list of options available for each theme see the documentation required for the theme used for linking to a specific tag in the website footer add any paths that contain custom themes here relative to this directory htmlthemepath the name for this set of sphinx documents if none it defaults to project vrelease documentation htmltitle none a shorter title for the navigation bar default is the same as htmltitle htmlshorttitle none the name of an image file relative to this directory to place at the top of the sidebar htmllogo none the name of an image file within the static path to use as favicon of the docs this file should be a windows icon file ico being 16x16 or 32x32 pixels large htmlfavicon none 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 if not a last updated on timestamp is inserted at every page bottom using the given strftime format htmllastupdatedfmt d b y if true smartypants will be used to convert quotes and dashes to typographically correct entities custom sidebar templates maps document names to template names htmlsidebars additional templates that should be rendered to pages maps page names to template names htmladditionalpages if false no module index is generated if false no index is generated we don t use the genindex if true the index is split into individual pages for each letter htmlsplitindex false if true links to the rest sources are added to the pages htmlshowsourcelink true if true created using sphinx is shown in the html footer default is true htmlshowsphinx true if true c is shown in the html footer default is true htmlshow true if true an opensearch description file will be output and all pages will contain a link tag referring to it the value of this option must be the base url from which the finished html is served htmluseopensearch this is the file name suffix for html files e g xhtml htmlfilesuffix none output file base name for html help builder options for latex output the paper size letterpaper or a4paper papersize letterpaper the font size 10pt 11pt or 12pt pointsize 10pt additional stuff for the latex preamble preamble grouping the document tree into latex files list of tuples source start file target name title documentclass howtomanual the name of an image file relative to this directory to place at the top of the title page latexlogo none for manual documents if this is true then toplevel headings are parts not chapters latexuseparts false if true show page references after internal links latexshowpagerefs false if true show url addresses after external links latexshowurls false documents to append as an appendix to all manuals latexappendices if false no module index is generated latexdomainindices true options for manual page output one entry per manual page list of tuples source start file name description s manual section if true show url addresses after external links manshowurls false options for texinfo output grouping the document tree into texinfo files list of tuples source start file target name title dir menu entry description category documents to append as an appendix to all manuals texinfoappendices if false no module index is generated texinfodomainindices true how to display url addresses footnote no or inline texinfoshowurls footnote options for autodoc output if it s mixed then the documentation for each parameter isn t listed e g nltk tokenize casual tweettokenizerpreservecasetrue reducelenfalse striphandlesfalse matchphonenumberstrue and that s it with seperated nltk tokenize casual tweettokenizer initpreservecasetrue reducelenfalse striphandlesfalse matchphonenumberstrue create a tweettokenizer instance with settings for use in the tokenize method parameters preservecase bool flag indicating whether to preserve the casing capitalisation of text used in the tokenize method defaults to true reducelen bool flag indicating whether to replace repeated character sequences of length 3 or greater with sequences of length 3 defaults to false striphandles bool flag indicating whether to remove twitter handles of text used in the tokenize method defaults to false matchphonenumbers bool flag indicating whether the tokenize method should look for phone numbers defaults to true put the python 3 5 type hint in the signature and also at the parameters list nltk documentation build configuration file sphinx quickstart on wed nov 2 17 02 59 2011 this file is execfile d with the current directory set to its containing dir note that not all possible configuration values are present in this autogenerated file all configuration values have a default values that are commented out serve to show the default if extensions or modules to document with autodoc are in another directory add these directories to sys path here if the directory is relative to the documentation root use os path abspath to make it absolute like shown here build docs using nltk from the upper dir not the installed version general configuration if your documentation needs a minimal sphinx version state it here needs_sphinx 2 2 add any sphinx extension module names here as strings they can be extensions coming with sphinx named sphinx ext or your custom ones generating contents in the howto folder based on the ntlk test doctest files as well as contents in the team folder based on team json load jinja template iterate over doctest files and find the module_name ignore index doctest we already have an index i e howto rst write rst files based on the doctest_template load the team json data load the team jinja template build the team howto page before creating the sphinx build add any paths that contain templates here relative to this directory the suffix of source filenames the encoding of source files source_encoding utf 8 sig the master toctree document general information about the project 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 the full version including alpha beta rc tags the language for content autogenerated by sphinx refer to documentation for a list of supported languages language none there are two options for replacing today either you set today to some non false value then it is used today else today_fmt is used as the format for a strftime call today_fmt b d y list of patterns relative to source directory that match files and directories to ignore when looking for source files the rest default role used for this markup text to use for all documents default_role none if true will be appended to func etc cross reference text add_function_parentheses true if true the current module name will be prepended to all description unit titles such as function add_module_names true if true section and module directives will be shown in the output they are ignored by default show_s false the name of the pygments syntax highlighting style to use a list of ignored prefixes for module index sorting options for html output the theme to use for html and html help pages see the documentation for a list of builtin themes 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 documentation required for the theme used for linking to a specific tag in the website footer add any paths that contain custom themes here relative to this directory html_theme_path the name for this set of sphinx documents if none it defaults to project v release documentation html_title none a shorter title for the navigation bar default is the same as html_title html_short_title none the name of an image file relative to this directory to place at the top of the sidebar html_logo none the name of an image file within the static path to use as favicon of the docs this file should be a windows icon file ico being 16x16 or 32x32 pixels large html_favicon none 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 if not a last updated on timestamp is inserted at every page bottom using the given strftime format html_last_updated_fmt d b y if true smartypants will be used to convert quotes and dashes to typographically correct entities custom sidebar templates maps document names to template names html_sidebars additional templates that should be rendered to pages maps page names to template names html_additional_pages if false no module index is generated if false no index is generated we don t use the genindex if true the index is split into individual pages for each letter html_split_index false if true links to the rest sources are added to the pages html_show_sourcelink true if true created using sphinx is shown in the html footer default is true html_show_sphinx true if true c is shown in the html footer default is true html_show_ true if true an opensearch description file will be output and all pages will contain a link tag referring to it the value of this option must be the base url from which the finished html is served html_use_opensearch this is the file name suffix for html files e g xhtml html_file_suffix none output file base name for html help builder options for latex output the paper size letterpaper or a4paper papersize letterpaper the font size 10pt 11pt or 12pt pointsize 10pt additional stuff for the latex preamble preamble grouping the document tree into latex files list of tuples source start file target name title documentclass howto manual the name of an image file relative to this directory to place at the top of the title page latex_logo none for manual documents if this is true then toplevel headings are parts not chapters latex_use_parts false if true show page references after internal links latex_show_pagerefs false if true show url addresses after external links latex_show_urls false documents to append as an appendix to all manuals latex_appendices if false no module index is generated latex_domain_indices true options for manual page output one entry per manual page list of tuples source start file name description s manual section if true show url addresses after external links man_show_urls false options for texinfo output grouping the document tree into texinfo files list of tuples source start file target name title dir menu entry description category documents to append as an appendix to all manuals texinfo_appendices if false no module index is generated texinfo_domain_indices true how to display url addresses footnote no or inline texinfo_show_urls footnote options for autodoc output if it s mixed then the documentation for each parameter isn t listed e g nltk tokenize casual tweettokenizer preserve_case true reduce_len false strip_handles false match_phone_numbers true and that s it with seperated nltk tokenize casual tweettokenizer __init__ preserve_case true reduce_len false strip_handles false match_phone_numbers true create a tweettokenizer instance with settings for use in the tokenize method parameters preserve_case bool flag indicating whether to preserve the casing capitalisation of text used in the tokenize method defaults to true reduce_len bool flag indicating whether to replace repeated character sequences of length 3 or greater with sequences of length 3 defaults to false strip_handles bool flag indicating whether to remove twitter handles of text used in the tokenize method defaults to false match_phone_numbers bool flag indicating whether the tokenize method should look for phone numbers defaults to true put the python 3 5 type hint in the signature and also at the parameters list
import os
import sys






sys.path.insert(0, os.path.abspath(".."))








extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.coverage",
    "sphinx.ext.imgmath",
    "sphinx.ext.viewcode",
    "sphinxcontrib.apidoc",
]

apidoc_module_dir = "../nltk"
apidoc_output_dir = "api"
apidoc_separate_modules = True
apidoc_extra_args = ["--templatedir=_templates", "--force"]
apidoc_excluded_paths = ["test"]


def generate_custom_files():
    
    import glob
    import json
    import re

    from jinja2 import Template

    modules = []

    web_folder = os.path.dirname(os.path.abspath(__file__))
    howto_folder = os.path.join(web_folder, "howto")
    if not os.path.exists(howto_folder):
        os.makedirs(howto_folder)

    
    with open(
        os.path.join(web_folder, "_templates", "doctest.rst"), encoding="utf8"
    ) as f:
        doctest_template = Template(f.read())

    print("Generating HOWTO pages...")
    
    pattern = re.compile(r"(\w+)\.doctest$")
    for path in glob.glob(os.path.join(web_folder, "..", "nltk", "test", "*.doctest")):
        match = pattern.search(path)
        module_name = match.group(1)
        
        if module_name == "index":
            continue
        
        doctest_template.stream(module_name=module_name).dump(
            os.path.join(howto_folder, f"{module_name}.rst")
        )
        modules.append(module_name)

    print(f"Generated {len(modules)} HOWTO pages.")

    
    with open(os.path.join(web_folder, "team", "team.json"), encoding="utf8") as f:
        full_data = json.load(f)
    print("Team data loaded!")

    
    with open(
        os.path.join(web_folder, "_templates", "team.html"), encoding="utf8"
    ) as f:
        team_template = Template(f.read())

    for members_type, members_data in full_data.items():
        team_template.stream(members=members_data).dump(
            os.path.join(web_folder, "team", f"{members_type}_team.html")
        )
        print(f"{members_type.title()} team HTML page written!")



generate_custom_files()


templates_path = ["_templates"]


source_suffix = ".rst"





master_doc = "index"


project = "NLTK"
copyright = "2023, NLTK Project"






version = "3.8.1"

release = "3.8.1"













exclude_patterns = ["_build", "api/modules.rst", "dev/*.rst"]
















pygments_style = "sphinx"


modindex_common_prefix = ["nltk."]






html_theme = "nltk_theme"





html_theme_options = {"navigation_depth": 1}

html_context = {"github_user": "nltk", "github_repo": "nltk"}























html_static_path = ["_static"]



html_last_updated_fmt = "%b %d, %Y"




html_use_smartypants = True









html_domain_indices = True



html_use_index = False






















htmlhelp_basename = "NLTKdoc"




latex_elements = {
    
    
    
    
    
    
}



latex_documents = [("index", "NLTK.tex", "NLTK Documentation", "Steven Bird", "manual")]


























man_pages = [("index", "nltk", "NLTK Documentation", ["Steven Bird"], 1)]










texinfo_documents = [
    (
        "index",
        "NLTK",
        "NLTK Documentation",
        "Steven Bird",
        "NLTK",
        "One line description of project.",
        "Miscellaneous",
    )
]
























autodoc_class_signature = "separated"


autodoc_typehints = "both"