2010-06-27 00:33:12 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
2014-06-13 15:19:58 +00:00
|
|
|
'''
|
|
|
|
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.
|
|
|
|
'''
|
|
|
|
|
2010-06-27 00:33:12 +00:00
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
|
|
import subprocess
|
2011-10-16 11:09:15 +00:00
|
|
|
import sys
|
2010-06-27 00:33:12 +00:00
|
|
|
|
|
|
|
import time
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
|
|
|
|
def man_format(data):
|
|
|
|
data = data.replace("-", "\\-")
|
2013-05-25 02:21:50 +00:00
|
|
|
data = data.replace("\t", " ")
|
2010-06-27 00:33:12 +00:00
|
|
|
return data
|
|
|
|
|
2014-06-13 15:19:58 +00:00
|
|
|
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]
|
2010-06-27 00:33:12 +00:00
|
|
|
|
2011-10-16 11:09:15 +00:00
|
|
|
cmd = [blender_bin, "--help"]
|
|
|
|
print(" executing:", " ".join(cmd))
|
2014-06-13 15:19:58 +00:00
|
|
|
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.
|
2010-06-27 00:33:12 +00:00
|
|
|
date_string = datetime.date.fromtimestamp(time.time()).strftime("%B %d, %Y")
|
|
|
|
|
2014-06-13 15:19:58 +00:00
|
|
|
outfile = open(outfilename, "w")
|
|
|
|
fw = outfile.write
|
2010-06-27 00:33:12 +00:00
|
|
|
|
|
|
|
fw('.TH "BLENDER" "1" "%s" "Blender %s"\n' % (date_string, blender_version.replace(".", "\\&.")))
|
|
|
|
|
|
|
|
fw('''
|
|
|
|
.SH NAME
|
|
|
|
blender \- a 3D modelling and rendering package''')
|
|
|
|
|
|
|
|
fw('''
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B blender [args ...] [file] [args ...]''')
|
|
|
|
|
|
|
|
fw('''
|
|
|
|
.br
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.PP
|
|
|
|
.B blender
|
2014-02-20 06:05:15 +00:00
|
|
|
is a 3D modelling and rendering package. Originating as the in-house software of a high quality animation studio, Blender has proven to be an extremely fast and versatile design instrument. The software has a personal touch, offering a unique approach to the world of Three Dimensions.
|
2010-06-27 00:33:12 +00:00
|
|
|
|
2014-02-20 06:05:15 +00:00
|
|
|
Use Blender to create TV commercials, to make technical visualizations, business graphics, to create content for games, or design user interfaces. You can easy build and manage complex environments. The renderer is versatile and extremely fast. All basic animation principles (curves & keys) are well implemented.
|
2010-06-27 00:33:12 +00:00
|
|
|
|
|
|
|
http://www.blender.org''')
|
|
|
|
|
|
|
|
fw('''
|
|
|
|
.SH OPTIONS''')
|
|
|
|
|
|
|
|
fw("\n\n")
|
|
|
|
|
|
|
|
lines = [line.rstrip() for line in blender_help.split("\n")]
|
|
|
|
|
|
|
|
while lines:
|
|
|
|
l = lines.pop(0)
|
|
|
|
if l.startswith("Environment Variables:"):
|
2010-07-13 23:51:21 +00:00
|
|
|
fw('.SH "ENVIRONMENT VARIABLES"\n')
|
2010-09-07 15:17:42 +00:00
|
|
|
elif l.endswith(":"): # one line
|
2010-07-13 23:51:21 +00:00
|
|
|
fw('.SS "%s"\n\n' % l)
|
2010-09-07 15:17:42 +00:00
|
|
|
elif l.startswith("-") or l.startswith("/"): # can be multi line
|
2010-06-27 00:33:12 +00:00
|
|
|
|
|
|
|
fw('.TP\n')
|
|
|
|
fw('.B %s\n' % man_format(l))
|
2010-07-13 23:51:21 +00:00
|
|
|
|
2010-06-27 00:33:12 +00:00
|
|
|
while lines:
|
2010-07-13 23:51:21 +00:00
|
|
|
# line with no
|
2010-09-07 15:17:42 +00:00
|
|
|
if lines[0].strip() and len(lines[0].lstrip()) == len(lines[0]): # no white space
|
2010-06-27 00:33:12 +00:00
|
|
|
break
|
|
|
|
|
2010-09-07 15:17:42 +00:00
|
|
|
if not l: # second blank line
|
2010-06-27 00:33:12 +00:00
|
|
|
fw('.IP\n')
|
|
|
|
else:
|
|
|
|
fw('.br\n')
|
|
|
|
|
|
|
|
l = lines.pop(0)
|
2010-09-07 15:17:42 +00:00
|
|
|
l = l[1:] # remove first whitespace (tab)
|
2010-06-27 00:33:12 +00:00
|
|
|
|
|
|
|
fw('%s\n' % man_format(l))
|
2010-07-13 23:51:21 +00:00
|
|
|
|
2010-06-27 00:33:12 +00:00
|
|
|
else:
|
|
|
|
if not l.strip():
|
|
|
|
fw('.br\n')
|
|
|
|
else:
|
|
|
|
fw('%s\n' % man_format(l))
|
|
|
|
|
|
|
|
# footer
|
|
|
|
|
|
|
|
fw('''
|
|
|
|
.br
|
|
|
|
.SH SEE ALSO
|
2014-02-20 06:05:15 +00:00
|
|
|
.B luxrender(1)
|
2010-06-27 00:33:12 +00:00
|
|
|
|
|
|
|
.br
|
|
|
|
.SH AUTHORS
|
|
|
|
This manpage was written for a Debian GNU/Linux system by Daniel Mester
|
|
|
|
<mester@uni-bremen.de> and updated by Cyril Brulebois
|
|
|
|
<cyril.brulebois@enst-bretagne.fr> and Dan Eicher <dan@trollwerks.org>.
|
|
|
|
''')
|
2010-07-15 19:58:23 +00:00
|
|
|
|
2014-06-13 15:19:58 +00:00
|
|
|
outfile.close()
|
|
|
|
print("written:", outfilename)
|