Browse Source

Fix doc build if git is absent

When building packages if git is absent, then we should not set
html_last_updated_fmt. It can still be set via the -D switch
when building with sphinx-build.

Change-Id: I2c219d64e33ab8af7e883e6153855d040d8f8f38
Closes-Bug: #1552251
tags/2.0.0
Thomas Bechtold 3 years ago
parent
commit
5024a8cb78
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      doc/source/conf.py

+ 7
- 2
doc/source/conf.py View File

@@ -6,6 +6,7 @@ import sys
6 6
 import os
7 7
 import fileinput
8 8
 import fnmatch
9
+import warnings
9 10
 
10 11
 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
11 12
 ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", ".."))
@@ -63,8 +64,12 @@ htmlhelp_basename = '%sdoc' % project
63 64
 
64 65
 git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
65 66
     "-n1"]
66
-html_last_updated_fmt = subprocess.Popen(
67
-    git_cmd, stdout=subprocess.PIPE).communicate()[0]
67
+try:
68
+    html_last_updated_fmt = subprocess.Popen(
69
+        git_cmd, stdout=subprocess.PIPE).communicate()[0]
70
+except Exception:
71
+    warnings.warn('Cannot get last updated time from git repository. '
72
+                  'Not setting "html_last_updated_fmt".')
68 73
 
69 74
 # Grouping the document tree into LaTeX files. List of tuples
70 75
 # (source start file, target name, title, author, documentclass

Loading…
Cancel
Save