if "DJANGO_SETTINGS_MODULE" not in os.environ: docs_path = os.getcwd() parts = (docs_path, "..", "mezzanine") sys.path.insert(0, os.path.join(*parts)) sys.path.insert(0, os.path.join(*parts + ("project_template", ))) settings_module = "mezzanine.project_template.settings" os.environ["DJANGO_SETTINGS_MODULE"] = settings_module # When a full build is run (eg from the root of the repo), we # run all the Mezzanine utils for dynamically generated docs. if sys.argv[-2:] == ["docs", "docs/build"]: from mezzanine.utils import docs docs.build_settings_docs(docs_path) docs.build_deploy_docs(docs_path) docs.build_changelog(docs_path) docs.build_modelgraph(docs_path) docs.build_requirements(docs_path) # 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. #sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # 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"] # Add any paths that contain templates here, relative to this directory.
sys.path.insert(0, os.path.realpath(os.path.join(*mezzanine_path_parts))) os.environ["DJANGO_SETTINGS_MODULE"] = "docs_settings" # Django 1.7's setup is required before touching translated strings. import django try: django.setup() except AttributeError: # < 1.7 pass # When a full build is run (eg from the root of the repo), we # run all the Mezzanine utils for dynamically generated docs. if sys.argv[-2:] == ["docs", "docs/build"]: from mezzanine.utils import docs docs.build_settings_docs(docs_path) docs.build_deploy_docs(docs_path) docs.build_changelog(docs_path) docs.build_modelgraph(docs_path) docs.build_requirements(docs_path) # 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. # sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # 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.viewcode"] # Add any paths that contain templates here, relative to this directory.
# # All configuration values have a default; values that are commented out # serve to show the default. import sys import os docs_path = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(docs_path, "..")) os.environ["DJANGO_SETTINGS_MODULE"] = "mezzanine.project_template.settings" import mezzanine from mezzanine.utils.docs import build_settings_docs, build_changelog build_settings_docs(docs_path) build_changelog(docs_path) # 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. #sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # 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"] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates']
cartridge_path_parts = (docs_path, "..") sys.path.insert(0, docs_path) sys.path.insert(0, os.path.realpath(os.path.join(*cartridge_path_parts))) os.environ["DJANGO_SETTINGS_MODULE"] = "docs_settings" # Django 1.7's setup is required before touching translated strings. import django try: django.setup() except AttributeError: # < 1.7 pass if sys.argv[-2:] == ["docs", "docs/build"]: import cartridge from mezzanine.utils import docs docs.build_settings_docs(docs_path, prefix="SHOP_") docs.build_changelog(docs_path, package_name="cartridge") #docs.build_modelgraph(docs_path, package_name="cartridge") try: from cartridge.shop.models import Order from cartridge.shop.forms import OrderForm fields = { "form": OrderForm(None, None).fields.keys(), "model": [f.name for f in Order._meta.fields], } for name, names in fields.items(): file_name = "order_%s_fields.rst" % name with open(os.path.join(docs_path, file_name), "w") as f: f.write(" * ``" + "``\n * ``".join(names) + "``") except Exception, e: print "Error generating docs for fields: %s" % e
# All configuration values have a default; values that are commented out # serve to show the default. import sys import os docs_path = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(docs_path, "..")) sys.path.insert(0, os.path.join(docs_path, "..", "..", "mezzanine")) os.environ["DJANGO_SETTINGS_MODULE"] = "cartridge.project_template.settings" import cartridge from mezzanine.utils import docs docs.build_settings_docs(docs_path, prefix="SHOP_") docs.build_changelog(docs_path, package_name="cartridge") docs.build_modelgraph(docs_path, package_name="cartridge") try: from cartridge.shop.models import Order from cartridge.shop.forms import OrderForm fields = { "form": OrderForm(None, None).fields.keys(), "model": [f.name for f in Order._meta.fields], } for name, names in fields.items(): file_name = "order_%s_fields.rst" % name with open(os.path.join(docs_path, file_name), "w") as f: f.write(" * ``" + "``\n * ``".join(names) + "``") except Exception, e: print "Error generating docs for fields: %s" % e