Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bug 801230 - Add a cfx sdocs option to override the version #604

Merged
merged 1 commit into from

1 participant

@wbamberg
Owner

No description provided.

@wbamberg wbamberg merged commit 56c8b59 into mozilla:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 13, 2012
  1. @wbamberg
This page is out of date. Refresh to see the latest.
View
11 python-lib/cuddlefish/__init__.py
@@ -194,6 +194,11 @@
metavar=None,
default=False,
cmds=['test', 'testex', 'testpkgs'])),
+ (("", "--override-version",), dict(dest="override_version",
+ help="Pass in a version string to use in generated docs",
+ metavar=None,
+ default=False,
+ cmds=['sdocs'])),
]
),
@@ -584,7 +589,11 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
return
elif command == "sdocs":
from cuddlefish.docs import generate
- filename = generate.generate_static_docs(env_root)
+ filename=""
+ if options.override_version:
+ filename = generate.generate_static_docs(env_root, override_version=options.override_version)
+ else:
+ filename = generate.generate_static_docs(env_root)
print >>stdout, "Wrote %s." % filename
return
elif command not in ["xpi", "test", "run"]:
View
19 python-lib/cuddlefish/docs/generate.py
@@ -9,6 +9,7 @@
import tarfile
import StringIO
+from cuddlefish._version import get_versions
from cuddlefish.docs import apiparser
from cuddlefish.docs import apirenderer
from cuddlefish.docs import webdocs
@@ -43,19 +44,19 @@ def clean_generated_docs(docs_dir):
if os.path.exists(api_doc_dir):
shutil.rmtree(api_doc_dir)
-def generate_static_docs(env_root):
+def generate_static_docs(env_root, override_version=get_versions()["version"]):
clean_generated_docs(get_sdk_docs_path(env_root))
- generate_docs(env_root, stdout=StringIO.StringIO())
+ generate_docs(env_root, override_version, stdout=StringIO.StringIO())
tgz = tarfile.open(TGZ_FILENAME, 'w:gz')
tgz.add(get_sdk_docs_path(env_root), "doc")
tgz.close()
return TGZ_FILENAME
def generate_local_docs(env_root):
- return generate_docs(env_root, get_base_url(env_root))
+ return generate_docs(env_root, get_versions()["version"], get_base_url(env_root))
def generate_named_file(env_root, filename_and_path):
- web_docs = webdocs.WebDocs(env_root, get_base_url(env_root))
+ web_docs = webdocs.WebDocs(env_root, get_versions()["version"], get_base_url(env_root))
abs_path = os.path.abspath(filename_and_path)
path, filename = os.path.split(abs_path)
if abs_path.startswith(os.path.join(env_root, 'doc', 'module-source')):
@@ -69,12 +70,12 @@ def generate_named_file(env_root, filename_and_path):
else:
raise ValueError("Not a valid path to a documentation file")
-def generate_docs(env_root, base_url=None, stdout=sys.stdout):
+def generate_docs(env_root, version=get_versions()["version"], base_url=None, stdout=sys.stdout):
docs_dir = get_sdk_docs_path(env_root)
# if the generated docs don't exist, generate everything
if not os.path.exists(os.path.join(docs_dir, "dev-guide")):
print >>stdout, "Generating documentation..."
- generate_docs_from_scratch(env_root, base_url)
+ generate_docs_from_scratch(env_root, version, base_url)
current_status = calculate_current_status(env_root)
open(os.path.join(docs_dir, DIGEST), "w").write(current_status)
else:
@@ -86,7 +87,7 @@ def generate_docs(env_root, base_url=None, stdout=sys.stdout):
# if the docs are not up to date, generate everything
if not docs_are_up_to_date:
print >>stdout, "Regenerating documentation..."
- generate_docs_from_scratch(env_root, base_url)
+ generate_docs_from_scratch(env_root, version, base_url)
open(os.path.join(docs_dir, DIGEST), "w").write(current_status)
return get_base_url(env_root) + "index.html"
@@ -114,9 +115,9 @@ def calculate_current_status(env_root):
current_status.update(str(os.path.getmtime(os.path.join(dirpath, base_html_file))))
return current_status.digest()
-def generate_docs_from_scratch(env_root, base_url):
+def generate_docs_from_scratch(env_root, version, base_url):
docs_dir = get_sdk_docs_path(env_root)
- web_docs = webdocs.WebDocs(env_root, base_url)
+ web_docs = webdocs.WebDocs(env_root, version, base_url)
must_rewrite_links = True
if base_url:
must_rewrite_links = False
View
6 python-lib/cuddlefish/docs/webdocs.py
@@ -32,8 +32,9 @@ def insert_after(target, insertion_point_id, text_to_insert):
return target[:insertion_point] + text_to_insert + target[insertion_point:]
class WebDocs(object):
- def __init__(self, root, base_url = None):
+ def __init__(self, root, version=get_versions()["version"], base_url = None):
self.root = root
+ self.version = version
self.pkg_cfg = packaging.build_pkg_cfg(root)
self.packages_json = packaging.build_pkg_index(self.pkg_cfg)
self.base_page = self._create_base_page(root, base_url)
@@ -69,8 +70,7 @@ def _create_base_page(self, root, base_url):
if base_url:
base_tag = 'href="' + base_url + '"'
base_page = insert_after(base_page, BASE_URL_INSERTION_POINT, base_tag)
- sdk_version = get_versions()["version"]
- base_page = insert_after(base_page, VERSION_INSERTION_POINT, "Version " + sdk_version)
+ base_page = insert_after(base_page, VERSION_INSERTION_POINT, "Version " + self.version)
module_list = get_module_list(os.sep.join([root, "doc", "module-source"]))
high_level_module_list = [module_info for module_info in module_list if module_info.level() == "high"]
high_level_module_text = self._make_module_text(high_level_module_list)
Something went wrong with that request. Please try again.