Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allowed update_docs to build non-English doc versions

  • Loading branch information...
commit 2e8f12a611555f0454748b7977a31eb1a65bf2c9 1 parent cb66da9
Claude Paroz authored June 13, 2013

Showing 1 changed file with 29 additions and 14 deletions. Show diff stats Hide diff stats

  1. 43  docs/management/commands/update_docs.py
43  docs/management/commands/update_docs.py
@@ -46,9 +46,13 @@ def handle_noargs(self, **kwargs):
46 46
             if verbosity >= 1:
47 47
                 print "Updating %s..." % release
48 48
 
49  
-            destdir = Path(settings.DOCS_BUILD_ROOT).child(release.lang, release.version)
50  
-            if not destdir.exists():
51  
-                destdir.mkdir(parents=True)
  49
+            # checkout_dir is shared for all languages.
  50
+            checkout_dir = Path(settings.DOCS_BUILD_ROOT).child(release.version)
  51
+            parent_build_dir = Path(settings.DOCS_BUILD_ROOT).child(release.lang, release.version)
  52
+            if not checkout_dir.exists():
  53
+                checkout_dir.mkdir(parents=True)
  54
+            if not parent_build_dir.exists():
  55
+                parent_build_dir.mkdir(parents=True)
52 56
 
53 57
             #
54 58
             # Update the release from SCM.
@@ -56,19 +60,29 @@ def handle_noargs(self, **kwargs):
56 60
 
57 61
             # Make an SCM checkout/update into the destination directory.
58 62
             # Do this dynamically in case we add other SCM later.
59  
-            getattr(self, 'update_%s' % release.scm)(release.scm_url, destdir)
  63
+            getattr(self, 'update_%s' % release.scm)(release.scm_url, checkout_dir)
60 64
 
61  
-            #
62  
-            # Use Sphinx to build the release docs into JSON and HTML documents.
63  
-            #
64 65
             if release.docs_subdir:
65  
-                source_dir = destdir.child(*release.docs_subdir.split('/'))
  66
+                source_dir = checkout_dir.child(*release.docs_subdir.split('/'))
66 67
             else:
67  
-                source_dir = destdir
  68
+                source_dir = checkout_dir
  69
+
  70
+            if release.lang != 'en':
  71
+                scm_url = release.scm_url.replace('django.git', 'django-docs-translations.git')
  72
+                trans_dir = checkout_dir.child('django-docs-translation')
  73
+                if not trans_dir.exists():
  74
+                    trans_dir.mkdir()
  75
+                getattr(self, 'update_%s' % release.scm)(scm_url, trans_dir)
  76
+                if not source_dir.child('locale').exists():
  77
+                    source_dir.child('locale').write_link(trans_dir.child('translations'))
  78
+                subprocess.call("cd %s && make translations" % trans_dir, shell=True)
68 79
 
  80
+            #
  81
+            # Use Sphinx to build the release docs into JSON and HTML documents.
  82
+            #
69 83
             for builder in ('json', 'html'):
70 84
                 # Wipe and re-create the build directory. See #18930.
71  
-                build_dir = destdir.child('_build', builder)
  85
+                build_dir = parent_build_dir.child('_build', builder)
72 86
                 if build_dir.exists():
73 87
                     shutil.rmtree(build_dir)
74 88
                 build_dir.mkdir(parents=True)
@@ -78,6 +92,7 @@ def handle_noargs(self, **kwargs):
78 92
                     print "  building %s (%s -> %s)" % (builder, source_dir, build_dir)
79 93
                 sphinx.cmdline.main(['sphinx-build',
80 94
                     '-b', builder,
  95
+                    '-D', 'language=%s' % release.lang,
81 96
                     '-q',              # Be vewy qwiet
82 97
                     source_dir,        # Source file directory
83 98
                     build_dir,         # Destination directory
@@ -87,7 +102,7 @@ def handle_noargs(self, **kwargs):
87 102
             # Create a zip file of the HTML build for offline reading.
88 103
             # This gets moved into STATIC_ROOT for downloading.
89 104
             #
90  
-            html_build_dir = destdir.child('_build', 'html')
  105
+            html_build_dir = parent_build_dir.child('_build', 'html')
91 106
             zipfile_name = 'django-docs-%s-%s.zip' % (release.version, release.lang)
92 107
             zipfile_path = Path(settings.STATIC_ROOT).child('docs', zipfile_name)
93 108
             if not zipfile_path.parent.exists():
@@ -106,8 +121,8 @@ def zipfile_inclusion_filter(f):
106 121
             # Copy the build results to the directory used for serving
107 122
             # the documentation in the least disruptive way possible.
108 123
             #
109  
-            build_dir = destdir.child('_build')
110  
-            built_dir = destdir.child('_built')
  124
+            build_dir = parent_build_dir.child('_build')
  125
+            built_dir = parent_build_dir.child('_built')
111 126
             subprocess.check_call(['rsync', '--archive', '--delete',
112 127
                     '--link-dest=' + build_dir, build_dir + '/', built_dir])
113 128
 
@@ -133,7 +148,7 @@ def zipfile_inclusion_filter(f):
133 148
             # We have to be a bit careful to reverse-engineer the correct
134 149
             # relative path component, especially for "index" documents,
135 150
             # otherwise the search results will be incorrect.
136  
-            json_built_dir = destdir.child('_built', 'json')
  151
+            json_built_dir = parent_build_dir.child('_built', 'json')
137 152
             for built_doc in json_built_dir.walk():
138 153
                 if built_doc.isfile() and built_doc.ext == '.fjson':
139 154
 

0 notes on commit 2e8f12a

Please sign in to comment.
Something went wrong with that request. Please try again.