Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-06-13 19:19:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-13 19:19:58 +0400
commitcb7915fc606846601ef43fc8804735006bbc0b31 (patch)
tree57313b95285e1344b6296de51cc427fd2c540ea6 /doc/manpage/blender.1.py
parent2ca497d84db81fee2521dc5f3c6d2165f47c05d6 (diff)
Automatically generate blender.1 man page during build process
Patch T40418 by Lawrence D'Oliveiro
Diffstat (limited to 'doc/manpage/blender.1.py')
-rwxr-xr-x[-rw-r--r--]doc/manpage/blender.1.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py
index 646b2aa374b..32e8cc06857 100644..100755
--- a/doc/manpage/blender.1.py
+++ b/doc/manpage/blender.1.py
@@ -18,6 +18,16 @@
#
# ##### END GPL LICENSE BLOCK #####
+'''
+This script generates the blender.1 man page, embedding the help text
+from the Blender executable itself. Invoke it as follows:
+
+ blender.1.py <path-to-blender> <output-filename>
+
+where <path-to-blender> is the path to the Blender executable,
+and <output-filename> is where to write the generated man page.
+'''
+
# <pep8 compliant>
import subprocess
@@ -33,26 +43,23 @@ def man_format(data):
data = data.replace("\t", " ")
return data
-# allow passing blender as argument
-if sys.argv[-1].endswith(os.sep + "blender"):
- blender_bin = sys.argv[-1]
-else:
- blender_bin = os.path.join(os.path.dirname(__file__), "../../blender.bin")
+if len(sys.argv) != 3:
+ import getopt
+ raise getopt.GetoptError("Usage: %s <path-to-blender> <output-filename>" % sys.argv[0])
+
+blender_bin = sys.argv[1]
+outfilename = sys.argv[2]
cmd = [blender_bin, "--help"]
print(" executing:", " ".join(cmd))
-blender_help = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].decode(encoding="utf-8")
-
-blender_version = subprocess.Popen([blender_bin, "--version"], stdout=subprocess.PIPE).communicate()[0].decode(encoding="utf-8").strip()
-blender_version = blender_version.split("Build")[0]
-
+blender_help = subprocess.check_output(cmd).decode(encoding="utf-8")
+blender_version = subprocess.check_output([blender_bin, "--version"]).decode(encoding="utf-8").strip()
+blender_version = blender_version.split("build")[0].rstrip()
+blender_version = blender_version.partition(" ")[2] # remove 'Blender' prefix.
date_string = datetime.date.fromtimestamp(time.time()).strftime("%B %d, %Y")
-filepath = os.path.splitext(__file__)[0]
-
-file = open(filepath, "w")
-
-fw = file.write
+outfile = open(outfilename, "w")
+fw = outfile.write
fw('.TH "BLENDER" "1" "%s" "Blender %s"\n' % (date_string, blender_version.replace(".", "\\&.")))
@@ -128,4 +135,5 @@ This manpage was written for a Debian GNU/Linux system by Daniel Mester
<cyril.brulebois@enst-bretagne.fr> and Dan Eicher <dan@trollwerks.org>.
''')
-print("written:", filepath)
+outfile.close()
+print("written:", outfilename)