# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import importlib from pathlib import Path
from docutils import nodes from docutils.parsers.rst import Directive from mots.config import FileConfig from mots.directory import Directory from mots.export import export_to_format from sphinx.util.docstrings import prepare_docstring from sphinx.util.docutils import ReferenceRole
lines.extend(
[ ".. note::", " moz.build files' implementation includes a ``Path`` class.",
]
)
path_docstring_minus_summary = prepare_docstring(m.Path.__doc__)[2:]
lines.extend([" " + line for line in path_docstring_minus_summary])
for subcontext, cls in sorted(m.SUBCONTEXTS.items()):
lines.extend(
[ ".. _mozbuild_subcontext_%s:" % subcontext, "", "Sub-Context: %s" % subcontext, "=============" + "=" * len(subcontext), "",
]
)
lines.extend(prepare_docstring(cls.__doc__)) if lines[-1]:
lines.append("")
for k, v in sorted(cls.VARIABLES.items()):
lines.extend(variable_reference(k, *v))
lines.extend(
[ "Variables", "=========", "",
]
)
for v in sorted(m.VARIABLES):
lines.extend(variable_reference(v, *m.VARIABLES[v]))
lines.extend(
[ "Functions", "=========", "",
]
)
for func in sorted(m.FUNCTIONS):
lines.extend(function_reference(func, *m.FUNCTIONS[func]))
for v in sorted(m.SPECIAL_VARIABLES):
lines.extend(special_reference(v, *m.SPECIAL_VARIABLES[v]))
return lines
def find_mots_config_path(app): """Find and return mots config path if it exists."""
base_path = Path(app.srcdir).parent
config_path = base_path / "mots.yaml" if config_path.exists(): return config_path
def export_mots(config_path): """Load mots configuration and export it to file.""" # Load from disk and initialize configuration and directory.
config = FileConfig(config_path)
config.load()
directory = Directory(config)
directory.load()
# Fetch file format (i.e., "rst") and export path.
frmt = config.config["export"]["format"]
path = config_path.parent / config.config["export"]["path"]
# We simply format out the documentation as rst then feed it back # into the parser for conversion. We don't even emit ourselves, so # there's no record of us.
self.state_machine.insert_input(format_module(module), fname)
return []
class Searchfox(ReferenceRole): """Role which links a relative path from the source to it's searchfox URL.
Can be used like:
See :searchfox:`browser/base/content/browser-places.js` for more details.
# Unlike typical Sphinx installs, our documentation is assembled from # many sources and staged in a common location. This arguably isn't a best # practice, but it was the easiest to implement at the time. # # Here, we invoke our custom code for staging/generating all our # documentation.
# Export and write "governance" documentation to disk.
config_path = find_mots_config_path(app) if config_path:
export_mots(config_path)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.