[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29726] trunk/blender: script to create a man page from blenders --help text, replaced the hand edited man page with this.

Campbell Barton ideasman42 at gmail.com
Sun Jun 27 02:33:12 CEST 2010


Revision: 29726
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29726
Author:   campbellbarton
Date:     2010-06-27 02:33:12 +0200 (Sun, 27 Jun 2010)

Log Message:
-----------
script to create a man page from blenders --help text, replaced the hand edited man page with this.

Modified Paths:
--------------
    trunk/blender/doc/blender.1
    trunk/blender/source/creator/creator.c

Added Paths:
-----------
    trunk/blender/doc/blender.1.py

Modified: trunk/blender/doc/blender.1
===================================================================
(Binary files differ)

Added: trunk/blender/doc/blender.1.py
===================================================================
--- trunk/blender/doc/blender.1.py	                        (rev 0)
+++ trunk/blender/doc/blender.1.py	2010-06-27 00:33:12 UTC (rev 29726)
@@ -0,0 +1,134 @@
+#!/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 #####
+
+# <pep8 compliant>
+
+import subprocess
+import os
+
+import time
+import datetime
+
+
+def man_format(data):
+    data = data.replace("-", "\\-")
+    data = data.replace("\t", "    ")
+    # data = data.replace("$", "\\fI")
+    
+    data_ls = []
+    for w in data.split():
+        if w.startswith("$"):
+            w = "\\fI" + w[1:] + "\\fR"
+           
+        data_ls.append(w)
+
+    data = data[:len(data) - len(data.lstrip())] + " ".join(data_ls)
+
+    return data
+
+
+blender_bin = os.path.join(os.path.dirname(__file__), "../blender")
+
+blender_help = subprocess.Popen([blender_bin, "--help"], stdout=subprocess.PIPE).communicate()[0].decode()
+
+blender_version = subprocess.Popen([blender_bin, "--version"], stdout=subprocess.PIPE).communicate()[0].decode().strip()
+blender_version = blender_version.split("Build")[0]
+
+date_string = datetime.date.fromtimestamp(time.time()).strftime("%B %d, %Y")
+
+filepath = __file__.replace(".py", "")
+
+file = open(filepath, "w")
+
+fw = file.write
+
+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
+is a 3D modelling and rendering package. It is 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.
+
+Use Blender to create TV commercials, to make technical visualizations, business graphics, to do some morphing, 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.
+
+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:"):
+        fw('.SH "ENVIRONMENT VARIABLES"\n') 
+    elif l.endswith(":"): # one line
+        fw('.SS "%s"\n\n' % l) 
+    elif l.startswith("-") or l.startswith("/"): # can be multi line
+
+        fw('.TP\n')
+        fw('.B %s\n' % man_format(l))
+        
+        while lines:
+            # line with no 
+            if lines[0].strip() and len(lines[0].lstrip()) == len(lines[0]): # no white space
+                break
+
+            if not l: # second blank line
+                fw('.IP\n')
+            else:
+                fw('.br\n')
+
+            l = lines.pop(0)
+            l = l[1:] # remove first whitespace (tab)
+
+            fw('%s\n' % man_format(l))
+    
+    else:
+        if not l.strip():
+            fw('.br\n')
+        else:
+            fw('%s\n' % man_format(l))
+
+# footer
+
+fw('''
+.br
+.SH SEE ALSO
+.B yafaray(1)
+
+.br
+.SH AUTHORS
+This manpage was written for a Debian GNU/Linux system by Daniel Mester
+<mester at uni-bremen.de> and updated by Cyril Brulebois
+<cyril.brulebois at enst-bretagne.fr> and Dan Eicher <dan at trollwerks.org>.
+''')


Property changes on: trunk/blender/doc/blender.1.py
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2010-06-27 00:03:34 UTC (rev 29725)
+++ trunk/blender/source/creator/creator.c	2010-06-27 00:33:12 UTC (rev 29726)
@@ -234,11 +234,11 @@
 	BLI_argsPrintArgDoc(ba, "--window-geometry");
 
 	printf("\n");
-	printf ("Game Engine specific options:\n");
+	printf ("Game Engine Specific Options:\n");
 	BLI_argsPrintArgDoc(ba, "-g");
 
 	printf("\n");
-	printf ("Misc options:\n");
+	printf ("Misc Options:\n");
 	BLI_argsPrintArgDoc(ba, "--debug");
 	BLI_argsPrintArgDoc(ba, "--debug-fpe");
 
@@ -273,10 +273,25 @@
 	printf ("Other Options:\n");
 	BLI_argsPrintOtherDoc(ba);
 
+	printf ("Argument Parsing:\n");
+	printf ("\targuments must be separated by white space. eg\n");
+	printf ("\t\t\"blender -ba test.blend\"\n");
+	printf ("\t...will ignore the 'a'\n");
+	printf ("\t\t\"blender -b test.blend -f8\"\n");
+	printf ("\t...will ignore 8 because there is no space between the -f and the frame value\n\n");
+
+	printf ("Argument Order:\n");
+	printf ("Arguments are executed in the order they are given. eg\n");
+	printf ("\t\t\"blender --background test.blend --render-frame 1 --render-output /tmp\"\n");
+	printf ("\t...will not render to /tmp because '--render-frame 1' renders before the output path is set\n");
+	printf ("\t\t\"blender --background --render-output /tmp test.blend --render-frame 1\"\n");
+	printf ("\t...will not render to /tmp because loading the blend file overwrites the render output that was set\n");
+	printf ("\t\t\"blender --background test.blend --render-output /tmp --render-frame 1\" works as expected.\n\n");
+
 	printf ("\nEnvironment Variables:\n");
 	printf ("  $HOME\t\t\tStore files such as .blender/ .B.blend .Bfs .Blog here.\n");
 	printf ("  $BLENDERPATH  System directory to use for data files and scripts.\n");
-	printf ("                For this build of blender the default BLENDERPATH is...\n");
+	printf ("                For this build of blender the default $BLENDERPATH is...\n");
 	printf ("                \"%s\"\n", blender_path);
 	printf ("                setting the $BLENDERPATH will override this\n");
 #ifdef WIN32
@@ -289,19 +304,6 @@
 #endif
 	printf ("  $PYTHONHOME   Path to the python directory, eg. /usr/lib/python.\n\n");
 
-	printf ("Note: Arguments must be separated by white space. eg:\n");
-	printf ("    \"blender -ba test.blend\"\n");
-	printf ("  ...will ignore the 'a'\n");
-	printf ("    \"blender -b test.blend -f8\"\n");
-	printf ("  ...will ignore 8 because there is no space between the -f and the frame value\n\n");
-
-	printf ("Note: Arguments are executed in the order they are given. eg:\n");
-	printf ("    \"blender --background test.blend --render-frame 1 --render-output /tmp\"\n");
-	printf ("  ...will not render to /tmp because '--render-frame 1' renders before the output path is set\n");
-	printf ("    \"blender --background --render-output /tmp test.blend --render-frame 1\"\n");
-	printf ("  ...will not render to /tmp because loading the blend file overwrites the render output that was set\n");
-	printf ("    \"blender --background test.blend --render-output /tmp --render-frame 1\" works as expected.\n\n");
-
 	exit(0);
 
 	return 0;





More information about the Bf-blender-cvs mailing list