Changeset 3027
- Timestamp:
- 05/31/06 13:44:14 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
djangoproject.com/django_website/apps/docs/parts/build_documentation.py
r3025 r3027 9 9 from django.conf import settings 10 10 from django import template 11 from django.db importmodels11 from django.db.models import get_app, get_models 12 12 from docutils import nodes, utils 13 13 from docutils.core import publish_parts … … 74 74 import runtests 75 75 76 # Manually set INSTALLED_APPS to point to the test app. 77 settings.INSTALLED_APPS = (runtests.APP_NAME,) 76 # An empty access of the settings to force the default options to be 77 # installed prior to assigning to them. 78 settings.INSTALLED_APPS 79 80 # Manually set INSTALLED_APPS to point to the test models. 81 settings.INSTALLED_APPS = runtests.ALWAYS_INSTALLED_APPS + [runtests.MODEL_TESTS_DIR_NAME + '.' + a for a in runtests.get_test_models()] 78 82 79 83 # Some of the test models need to know whether the docs are being built. … … 81 85 82 86 for model_name in runtests.get_test_models(): 83 mod = models.get_app(model_name)87 mod = get_app(model_name) 84 88 85 89 out_file = os.path.join(settings.DJANGO_DOCUMENT_ROOT_PATH, 'model_' + model_name + '.html') … … 87 91 88 92 # Clean up the title and blurb. 89 title, blurb = mod.__doc__.strip().split('\n', 1) 93 try: 94 title, blurb = mod.__doc__.strip().split('\n', 1) 95 except ValueError: 96 sys.stderr.write("title and blurb not found in %s model test.\n" % model_name) 97 continue 90 98 parts = publish_parts( 91 99 blurb, … … 96 104 ) 97 105 blurb = parts["html_body"] 98 api_usage = mod.API_TESTS 106 try: 107 api_usage = mod.API_TESTS 108 except AttributeError: 109 continue # This model didn't have API_TESTS. 99 110 100 111 # Get the source code of the model, without the docstring or the … … 108 119 109 120 models = [] 110 for m in mod._MODELS:121 for m in get_models(mod): 111 122 models.append({ 112 123 'name': m._meta.object_name, … … 123 134 fp = open(out_file, 'w') 124 135 except IOError: 125 sys.stderr.write("Couldn't write to %s.\n" % file_name)136 sys.stderr.write("Couldn't write to %s.\n" % out_file) 126 137 continue 127 138 else: … … 132 143 fp = open(toc_file, 'w') 133 144 except IOError: 134 sys.stderr.write("Couldn't write to %s.\n" % file_name)145 sys.stderr.write("Couldn't write to %s.\n" % toc_file) 135 146 continue 136 147 else:
