Permalink
Browse files

Add option to build all dependencies

  • Loading branch information...
1 parent ed85922 commit 916dcaa2c7aeaa3a1e885c6fc7f80c4d3686ee0b @lazka lazka committed Mar 10, 2014
Showing with 40 additions and 14 deletions.
  1. +3 −0 README.rst
  2. +15 −3 pgi-docgen.py
  3. +17 −0 pgidocgen/namespace.py
  4. +3 −11 pgidocgen/repo.py
  5. +2 −0 pgidocgen/util.py
View
@@ -32,6 +32,9 @@ How do I get started?
# API docs for Gtk/Gst:
./build.sh Gtk-3.0 Gst-1.0
+ # API docs for Atk including all dependencies (GLib, GObject)
+ ./build.sh -d Atk-1.0
+
# On Windows:
build.bat Gtk-3.0 Gst-1.0
View
@@ -21,6 +21,7 @@
pgi.set_backend("ctypes,null")
from pgidocgen.main import MainGenerator
+from pgidocgen.namespace import get_namespace
from pgidocgen.util import get_gir_files
@@ -29,12 +30,17 @@ def main(argv):
description='Create a sphinx environ')
parser.add_argument('-f', '--force', action='store_true',
help="Remove the target path if it exists")
+ parser.add_argument('-d', '--dependencies', action='store_true',
+ help="Build all dependencies recursively")
parser.add_argument('target', help='path to where the result should be')
parser.add_argument('namespaces', nargs='+',
help='A list of namespaces including versions '
'(e.g. "Gtk-3.0 GLib-2.0")')
- args = parser.parse_args(argv[1:])
+ try:
+ args = parser.parse_args(argv[1:])
+ except SystemExit:
+ raise SystemExit(1)
if not is_pgi and args.namespaces:
print "Can't build API docs without pgi"
@@ -66,9 +72,15 @@ def main(argv):
print "Target already exists (pass -f to ignore): %s" % dest_dir
raise SystemExit(1)
+ to_build = [tuple(n.split("-")) for n in filtered]
+ if args.dependencies:
+ print "Dependencies will be build"
+ for mod in to_build[:]:
+ to_build.extend(get_namespace(*mod).get_all_dependencies())
+ to_build = set(to_build)
+
gen = MainGenerator(dest_dir)
- for name in filtered:
- namespace, version = name.split("-")
+ for namespace, version in to_build:
print "Create docs: Namespace=%s, Version=%s" % (namespace, version)
if namespace == "cairo":
print "cairo gets referenced to external docs, skipping"
View
@@ -67,6 +67,23 @@ def path(self):
def get_dependencies(self):
return list(self._dependencies)
+ def get_all_dependencies(self):
+ loaded = []
+ to_load = self.get_dependencies()
+ while to_load:
+ key = to_load.pop()
+ if key in loaded:
+ continue
+ sub_ns = get_namespace(*key)
+ loaded.append(key)
+ to_load.extend(sub_ns.get_dependencies())
+
+ return loaded
+
+ def __repr__(self):
+ return "%s(%s, %s)" % (
+ type(self).__name__, self.namespace, self.version)
+
def _parse_types(dom, namespace):
"""Create a mapping of various C names to python names"""
View
@@ -134,19 +134,10 @@ def __init__(self, namespace, version):
self._private = ns.parse_private()
- loaded = {}
- to_load = ns.get_dependencies()
- while to_load:
- key = to_load.pop()
- if key in loaded:
- continue
- sub_ns = get_namespace(*key)
- loaded[key] = sub_ns
- to_load.extend(sub_ns.get_dependencies())
-
# merge all type mappings
self._types = {}
- for sub_ns in loaded.values():
+ loaded = [ns] + [get_namespace(*x) for x in ns.get_all_dependencies()]
+ for sub_ns in loaded:
self._types.update(sub_ns.get_types())
self._types.update(ns.get_types())
@@ -254,6 +245,7 @@ def parse_constant(self, name):
def parse_class(self, name, obj, add_bases=False):
names = []
+ name = str(name)
current_rst_target = obj.__module__ + "." + obj.__name__
if add_bases:
View
@@ -34,6 +34,8 @@ def iter_public_attr(obj):
def import_namespace(namespace, version):
+ namespace = str(namespace)
+
import gi
try:
gi.require_version(namespace, version)

0 comments on commit 916dcaa

Please sign in to comment.