From: <cd...@us...> - 2012-03-25 22:57:27
|
Revision: 10060 http://octave.svn.sourceforge.net/octave/?rev=10060&view=rev Author: cdf Date: 2012-03-25 22:57:18 +0000 (Sun, 25 Mar 2012) Log Message: ----------- new package generate_latex Modified Paths: -------------- trunk/octave-forge/extra/generate_latex/DESCRIPTION trunk/octave-forge/extra/generate_latex/INDEX trunk/octave-forge/extra/generate_latex/inst/private/get_header_title_and_footer.m Added Paths: ----------- trunk/octave-forge/extra/generate_latex/ trunk/octave-forge/extra/generate_latex/inst/generate_package_latex.m trunk/octave-forge/extra/generate_latex/inst/get_latex_options.m trunk/octave-forge/extra/generate_latex/inst/latex_help_text.m trunk/octave-forge/extra/generate_latex/inst/private/get_main_filename.m trunk/octave-forge/extra/generate_latex/inst/private/get_main_header_title_and_footer.m Removed Paths: ------------- trunk/octave-forge/extra/generate_latex/inst/generate_alphabet.m trunk/octave-forge/extra/generate_latex/inst/generate_html_manual.m trunk/octave-forge/extra/generate_latex/inst/generate_operators.m trunk/octave-forge/extra/generate_latex/inst/generate_package_html.m trunk/octave-forge/extra/generate_latex/inst/get_html_options.m trunk/octave-forge/extra/generate_latex/inst/html_help_text.m trunk/octave-forge/extra/generate_latex/inst/private/find_package.m trunk/octave-forge/extra/generate_latex/inst/private/get_alpha_database.m trunk/octave-forge/extra/generate_latex/inst/private/get_index_header_title_and_footer.m trunk/octave-forge/extra/generate_latex/inst/private/get_overview_filename.m trunk/octave-forge/extra/generate_latex/inst/private/get_overview_header_title_and_footer.m trunk/octave-forge/extra/generate_latex/inst/private/get_pkg_list_item_filename.m trunk/octave-forge/extra/generate_latex/inst/private/get_root.m trunk/octave-forge/extra/generate_latex/inst/private/get_texi_conf.m trunk/octave-forge/extra/generate_latex/inst/private/get_txi_files.m trunk/octave-forge/extra/generate_latex/inst/private/mk_chapter_dir.m trunk/octave-forge/extra/generate_latex/inst/private/mk_various_dir.m trunk/octave-forge/extra/generate_latex/inst/private/octave_forge_seealso.m trunk/octave-forge/extra/generate_latex/inst/texi2html.m trunk/octave-forge/extra/generate_latex/inst/txi2index.m trunk/octave-forge/extra/generate_latex/inst/txi2reference.m Modified: trunk/octave-forge/extra/generate_latex/DESCRIPTION =================================================================== --- trunk/octave-forge/extra/generate_html/DESCRIPTION 2012-03-08 16:23:48 UTC (rev 9788) +++ trunk/octave-forge/extra/generate_latex/DESCRIPTION 2012-03-25 22:57:18 UTC (rev 10060) @@ -1,14 +1,12 @@ -Name: generate_html -Version: 0.1.3 -Date: 2010-02-25 -Author: Søren Hauberg -Maintainer: Søren Hauberg -Title: Generate HTML web page from help texts -Description: This package provides functions for generating HTML pages that - contain the help texts for a set of functions. The package is designed to be - as general as possible, but also contains convenience functions for generating - a set of pages for entire packages. -Depends: octave (>= 3.2.0) +Name: generate_latex +Version: 0.0.1 +Date: 2012-03-26 +Author: Soeren Hauberg, Carlo de Falco +Maintainer: Carlo de Falco +Title: Generate LaTeX docs from help texts +Description: This package provides functions for generating a LaTeX document + containing the help texts for a set of functions. +Depends: octave (>= 3.6.0) SystemRequirements: makeinfo License: GPL version 3 or later Modified: trunk/octave-forge/extra/generate_latex/INDEX =================================================================== --- trunk/octave-forge/extra/generate_html/INDEX 2012-03-08 16:23:48 UTC (rev 9788) +++ trunk/octave-forge/extra/generate_latex/INDEX 2012-03-25 22:57:18 UTC (rev 10060) @@ -1,12 +1,7 @@ -generate_html >> Generate HTML web page from help texts +generate_latex >> Generate LaTeX documents from help texts Single function functions - html_help_text + latex_help_text Package functions - generate_package_html - get_html_options - generate_html_manual -Utility Functions - txi2index - txi2reference - texi2html + generate_package_latex + get_latex_options Deleted: trunk/octave-forge/extra/generate_latex/inst/generate_alphabet.m =================================================================== --- trunk/octave-forge/extra/generate_html/inst/generate_alphabet.m 2012-03-08 16:23:48 UTC (rev 9788) +++ trunk/octave-forge/extra/generate_latex/inst/generate_alphabet.m 2012-03-25 22:57:18 UTC (rev 10060) @@ -1,105 +0,0 @@ -## Copyright (C) 2008 Soren Hauberg -## -## 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 3 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; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} generate_alphabet (@var{directory}, @var{data_file}, @ -## @var{root}, @var{options}) -## @end deftypefn - -function generate_alphabet (directory, data_file, root, options = struct ()) - ## Check input - if (!ischar (directory)) - error ("generate_alphabet: first input argument must be a string"); - endif - - if (!ischar (data_file)) - error ("generate_alphabet: second input argument must be a string"); - endif - - if (!ischar (root)) - error ("generate_alphabet: third input argument must be a string"); - endif - - ## If options is a string, call get_html_options - if (ischar (options)) - options = get_html_options (options); - elseif (!isstruct (options)) - error ("generate_alphabet: fourth input argument must be a string or a structure"); - endif - - ## Load data - data = load (data_file); - data = data.functions; - - ## Sort data - data = sort (data); - - ## Convert data to lower case but also keep the original in memory - ldata = lower (data); - - ## Iterate over each function - ## First we find the first function that starts with 'a' - for a = 1:length (data) - if (ldata {a}(1) >= "a") - break; - endif - endfor - - ## Then we iterate over each function until we get something that doesn't start with 'z' - current = data {a}(1); - [fid, footer] = new_file (directory, current, options); - for idx = a:length (data) - ## Are we still working on the same file - if (ldata {idx}(1) != current) - fprintf (fid, "</div\n%s", footer); - fclose (fid); - current = ldata {idx}(1); - [fid, footer] = new_file (directory, current, options); - endif - - ## Write the actual function to the file - fun = data {idx}; - fprintf (fid, "<div class=\"func\"><b><a href=\"%s/function/%s.html\">%s</a></b></div>\n", - root, fun, fun); - try - sentence = get_first_help_sentence (fun, 200); - catch - warning ("Marking '%s' as not implemented", fun); - sentence = "Not implemented"; - end_try_catch - fprintf (fid, "<div class=\"ftext\">%s</div>\n", sentence); - endfor - - fprintf (fid, "</div\n%s", footer); - fclose (fid); -endfunction - -function [fid, footer] = new_file (directory, current, options) - current = upper (current); - filename = fullfile (directory, sprintf ("%s.html", current)); - fid = fopen (filename, "w"); - if (fid <= 0) - error ("generate_alphabet: could not open '%s' for writing", filename); - endif - - options.body_command = 'onload="javascript:fix_top_menu (); javascript:alphabetical_menu ();"'; - title = sprintf ("Alphabetical List of Functions: %s", current); - [header, title, footer] = get_overview_header_title_and_footer (options, title, "../"); - - fprintf (fid, "%s\n", header); - fprintf (fid, "<h2><a name=\"%s\">%s</a></h2>\n<div>\n", current, current); -endfunction - Deleted: trunk/octave-forge/extra/generate_latex/inst/generate_html_manual.m =================================================================== --- trunk/octave-forge/extra/generate_html/inst/generate_html_manual.m 2012-03-08 16:23:48 UTC (rev 9788) +++ trunk/octave-forge/extra/generate_latex/inst/generate_html_manual.m 2012-03-25 22:57:18 UTC (rev 10060) @@ -1,148 +0,0 @@ -## Copyright (C) 2008 Soren Hauberg -## -## 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 3 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; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} generate_html_manual (@var{srcdir}, @var{outdir}) -## @end deftypefn - -function generate_html_manual (srcdir, outdir = "htdocs", options = struct ()) - ## Check input - if (nargin == 0) - print_usage (); - endif - - if (!ischar (srcdir)) - error ("generate_html_manual: first input argument must be a string"); - endif - - if (!ischar (outdir)) - error ("generate_html_manual: second input argument must be a string"); - endif - - ## If options is a string, call get_html_options - if (ischar (options)) - options = get_html_options (options); - elseif (!isstruct (options)) - error ("generate_html_manual: third input argument must be a string or a structure"); - endif - - ## Create directories - if (!exist (outdir, "dir")) - mkdir (outdir); - endif - %outdir = fullfile (outdir, "octave"); - %if (!exist (outdir, "dir")) - % mkdir (outdir); - %endif - - %chapter_dir = mk_chapter_dir (outdir, options); - %mk_function_dir (outdir, options); - % - %ds_handler = @(fun) docstring_handler (fun); - - ## Get file list - %file_list = get_txi_files (srcdir); - %txi_dir = fileparts (file_list {1}); - % - %texi_header = sprintf ("%s\n", get_texi_conf (srcdir)); - - ## Copy images from Octave build - %txi_dir = fullfile (srcdir, "doc", "interpreter"); - %pngs = fullfile (txi_dir, "*.png"); - %copyfile (pngs, "."); - - ## Set javascript startup - %if (!isfield (options, "body_command")) - % if (isfield (options, "manual_body_cmd")) - % options.body_command = options.manual_body_cmd; - % else - % options.body_command = ""; # XXX: do we need this? - % endif - %endif - - ## Process each file - %for k = 1:length (file_list) - % file = file_list {k}; - % [notused, name] = fileparts (file); - % - % text = txi2reference (file, ds_handler); - % - % text = strcat (texi_header, text); - % - % ## Remove numbers from headings as this has been broken since we handle - % ## each chapter as a seperate file - % text = strrep (text, "@chapter", "@unnumbered"); - % text = strrep (text, "@appendix", "@unnumbered"); - % text = strrep (text, "@section", "@unnumberedsec"); - % text = strrep (text, "@subsection", "@unnumberedsubsec"); - % text = strrep (text, "@subsubsection", "@unnumberedsubsubsec"); - % - % ## Make sure any @include's work - % include = "@include "; - % include_with_path = sprintf ("@include %s%s", txi_dir, filesep ()); - % text = strrep (text, include, include_with_path); - % - % ## Add 'op' index - % text = strcat ("@defindex op\n\n", text); - % - % ## Convert to HTML and write to disc - % [header, body, footer] = texi2html (text, options, "../../"); - % - % fid = fopen (fullfile (chapter_dir, sprintf ("%s.html", name)), "w"); - % fprintf (fid, "%s\n%s\n%s\n", header, body, footer); - % fclose (fid); - %endfor - - ## Move images into the chapter dir - %movefile ("*.png", chapter_dir); - - ################################################### - ## Generate reference for individual functions ## - ################################################### - - ## Get INDEX structure - indices = txi2index (srcdir); - index = struct (); - index.provides = {}; - index.name = "octave"; - index.description = "GNU Octave comes with a large set of general-prupose functions that are listed below. This is the core set of functions that is available without any packages installed."; - for k = 1:length (indices) - if (!isempty (indices {k})) - ikp = indices {k}.provides; - index.provides (end+1:end+length (ikp)) = ikp; - endif - endfor - - ## Generate the documentation - options.include_package_list_item = false; - options.include_package_page = false; - options.include_package_license = false; - - generate_package_html (index, outdir, options); - %for k = 1:length (index) - % if (!isempty (index {k})) - % printf ("Chapter: %s\n", index {k}.name); fflush (stdout); - % index {k}.name = ""; # remove the name to avoid each chapter having its own dir - % generate_package_html (index {k}, outdir, options); - % endif - %endfor -endfunction - -function retval = docstring_handler (fun) - retval = sprintf ("@ifhtml\n@html\n<div class='seefun'>See <a href='../function/%s.html'>%s</a></div>\n@end html\n@end ifhtml\n", - fun, fun); -endfunction - Deleted: trunk/octave-forge/extra/generate_latex/inst/generate_operators.m =================================================================== --- trunk/octave-forge/extra/generate_html/inst/generate_operators.m 2012-03-08 16:23:48 UTC (rev 9788) +++ trunk/octave-forge/extra/generate_latex/inst/generate_operators.m 2012-03-25 22:57:18 UTC (rev 10060) @@ -1,127 +0,0 @@ -## Copyright (C) 2008 Soren Hauberg -## -## 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 3 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; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} generate_operators (@var{outdir}, @var{options}) -## Generate a HTML page with a list of operators available in GNU Octave. -## @end deftypefn - -function generate_operators (outdir = "htdocs", options = struct ()) - ## Check input - if (!ischar (outdir)) - error ("generate_operators: first input argument must be a string"); - endif - - ## If options is a string, call get_html_options - if (ischar (options)) - options = get_html_options (options); - elseif (!isstruct (options)) - error ("generate_operators: second input argument must be a string or a structure"); - endif - - ## Create directories if needed - if (!exist (outdir, "dir")) - mkdir (outdir); - endif - name = fullfile (outdir, "operators.html"); - - ## Generate html - title = "Operators and Keywords"; - options.body_command = 'onload="javascript:fix_top_menu ();"'; - [header, title, footer] = get_overview_header_title_and_footer (options, title); - - fid = fopen (name, "w"); - if (fid < 0) - error ("generate_operators: couldn't open file for writing"); - endif - - fprintf (fid, "%s\n", header); - - fprintf (fid, "<h2 class=\"tbdesc\">Operators</h2>\n\n"); - write_list (__operators__, fid, false); - - fprintf (fid, "<h2 class=\"tbdesc\">Keywords</h2>\n\n"); - write_list (__keywords__, fid, true); - - fprintf (fid, "\n%s\n", footer); - fclose (fid); -endfunction - -function write_list (list, fid, write_anchors) - for k = 1:length (list) - elem = list {k}; - [text, format] = get_help_text (elem); - if (strcmp (format, "texinfo")) - text = strip_defs (text); - text = __makeinfo__ (text, "plain text"); - endif - if (write_anchors) - fprintf (fid, "<a name=\"%s\">\n", elem); - endif - fprintf (fid, "<div class=\"func\"><b>%s</b></div>\n", elem); - fprintf (fid, "<div class=\"ftext\">%s</div>\n", text); # XXX: don't use text - if (write_anchors) - fprintf (fid, "</a>\n\n"); - endif - endfor -endfunction - -function text = strip_defs (text) - ## Lines ending with "@\n" are continuation lines, so they should be concatenated - ## with the following line. - text = strrep (text, "@\n", " "); - - ## Find, and remove, lines that start with @def. This should remove things - ## such as @deftypefn, @deftypefnx, @defvar, etc. - keep = true (size (text)); - def_idx = strfind (text, "@def"); - if (!isempty (def_idx)) - endl_idx = find (text == "\n"); - for k = 1:length (def_idx) - endl = endl_idx (find (endl_idx > def_idx (k), 1)); - if (isempty (endl)) - keep (def_idx (k):end) = false; - else - keep (def_idx (k):endl) = false; - endif - endfor - - ## Remove the @end ... that corresponds to the @def we removed above - def1 = def_idx (1); - space_idx = find (text == " "); - space_idx = space_idx (find (space_idx > def1, 1)); - bracket_idx = find (text == "{" | text == "}"); - bracket_idx = bracket_idx (find (bracket_idx > def1, 1)); - if (isempty (space_idx) && isempty (bracket_idx)) - error ("generate_operators: couldn't parse texinfo"); - endif - sep_idx = min (space_idx, bracket_idx); - def_type = text (def1+1:sep_idx-1); - - end_idx = strfind (text, sprintf ("@end %s", def_type)); - if (isempty (end_idx)) - error ("generate_operators: couldn't parse texinfo"); - endif - endl = endl_idx (find (endl_idx > end_idx, 1)); - if (isempty (endl)) - keep (end_idx:end) = false; - else - keep (end_idx:endl) = false; - endif - - text = text (keep); - endif -endfunction Deleted: trunk/octave-forge/extra/generate_latex/inst/generate_package_html.m =================================================================== --- trunk/octave-forge/extra/generate_html/inst/generate_package_html.m 2012-03-08 16:23:48 UTC (rev 9788) +++ trunk/octave-forge/extra/generate_latex/inst/generate_package_html.m 2012-03-25 22:57:18 UTC (rev 10060) @@ -1,436 +0,0 @@ -## Copyright (C) 2008 Soren Hauberg -## -## 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 3 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; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} generate_package_html (@var{name}, @var{outdir}, @var{options}) -## Generate @t{HTML} documentation for a package. -## -## The function reads information about package @var{name} using the -## package system. This is then used to generate bunch of -## @t{HTML} files; one for each function in the package, and one overview -## page. The files are all placed in the directory @var{outdir}, which defaults -## to the current directory. The @var{options} structure is used to control -## the design of the web pages. -## -## As an example, the following code generates the web pages for the @t{image} -## package, with a design suitable for the @t{Octave-Forge} project. -## -## @example -## options = get_html_options ("octave-forge"); -## generate_package_html ("image", "image_html", options); -## @end example -## -## The resulting files will be available in the @t{"image_html"} directory. The -## overview page will be called @t{"image_html/overview.html"}. -## -## As a convenience, if @var{options} is a string, a structure will -## be generated by calling @code{get_html_options}. This means the above -## example can be reduced to the following. -## -## @example -## generate_package_html ("image", "image_html", "octave-forge"); -## @end example -## -## It should be noted that the function only works for installed packages. -## @seealso{get_html_options} -## @end deftypefn - -function generate_package_html (name = [], outdir = "htdocs", options = struct ()) - ## Check input - if (isempty (name)) - list = pkg ("list"); - for k = 1:length (list) - generate_package_html (list {k}.name, outdir, options); - endfor - return; - elseif (isstruct (name)) - desc = name; - if (isfield (name, "name")) - packname = desc.name; - else - packname = ""; - endif - elseif (ischar (name)) - packname = name; - pkg ("load", name); - desc = pkg ("describe", name) {1}; - else - error (["generate_package_html: first input must either be the name of a ", ... - "package, or a structure giving its description."]); - endif - - if (isempty (outdir)) - outdir = packname; - elseif (!ischar (outdir)) - error ("generate_package_html: second input argument must be a string"); - endif - - ## Create output directory if needed - if (!exist (outdir, "dir")) - mkdir (outdir); - endif - - packdir = fullfile (outdir, packname); - if (!exist (packdir, "dir")) - mkdir (packdir); - endif - - [local_fundir, fundir] = mk_function_dir (packdir, packname, options); - - ## If options is a string, call get_html_options - if (ischar (options)) - options = get_html_options (options); - elseif (!isstruct (options)) - error ("generate_package_html: third input argument must be a string or a structure"); - endif - - ################################################## - ## Generate html pages for individual functions ## - ################################################## - - ## Set javascript startup - if (!isfield (options, "body_command")) - if (isfield (options, "pack_body_cmd")) - options.body_command = options.pack_body_cmd; - else - options.body_command = ""; - endif - endif - - options.footer = strrep (options.footer, "%package", packname); - - num_categories = length (desc.provides); - anchors = implemented = cell (1, num_categories); - for k = 1:num_categories - F = desc.provides {k}.functions; - category = desc.provides {k}.category; - anchors {k} = strrep (category, " ", ""); # anchor names - - ## For each function in category - num_functions = length (F); - implemented {k} = cell (1, num_functions); - for l = 1:num_functions - fun = F {l}; - if (any (fun == filesep ())) - at_dir = fileparts (fun); - mkdir (fullfile (fundir, at_dir)); - r = "../../../"; - else - r = "../../"; - endif - outname = fullfile (fundir, sprintf ("%s.html", fun)); - try - html_help_text (fun, outname, options, r); - implemented {k}{l} = true; - catch - warning ("marking '%s' as not implemented", fun); - implemented {k}{l} = false; - end_try_catch - endfor - endfor - - ######################### - ## Write overview file ## - ######################### - first_sentences = cell (1, num_categories); - if (isfield (options, "include_overview") && options.include_overview) - overview_filename = get_overview_filename (options, desc.name); - - fid = fopen (fullfile (packdir, overview_filename), "w"); - if (fid < 0) - error ("generate_package_html: couldn't open overview file for writing"); - endif - - [header, title, footer] = get_overview_header_title_and_footer (options, desc.name, "../"); - - fprintf (fid, "%s\n", header); - fprintf (fid, "<h2 class=\"tbdesc\">%s</h2>\n\n", desc.name); - - fprintf (fid, " <div class=\"package_description\">\n"); - fprintf (fid, " %s\n", desc.description); - fprintf (fid, " </div>\n\n"); - - fprintf (fid, "<p>Select category: <select name=\"cat\" onchange=\"location = this.options[this.selectedIndex].value;\">\n"); - for k = 1:num_categories - category = desc.provides {k}.category; - fprintf (fid, " <option value=\"#%s\">%s</option>\n", anchors {k}, category); - endfor - fprintf (fid, " </select></p>\n\n"); - - ## Generate function list by category - for k = 1:num_categories - F = desc.provides {k}.functions; - category = desc.provides {k}.category; - fprintf (fid, " <h3 class=\"category\"><a name=\"%s\">%s</a></h3>\n\n", - anchors {k}, category); - - first_sentences {k} = cell (1, length (F)); - - ## For each function in category - for l = 1:length (F) - fun = F {l}; - if (implemented {k}{l}) - first_sentences {k}{l} = get_first_help_sentence (fun, 200); - first_sentences {k}{l} = strrep (first_sentences {k}{l}, "\n", " "); - - link = sprintf ("%s/%s.html", local_fundir, fun); - fprintf (fid, " <div class=\"func\"><b><a href=\"%s\">%s</a></b></div>\n", - link, fun); - fprintf (fid, " <div class=\"ftext\">%s</div>\n\n", first_sentences {k}{l}); - else - fprintf (fid, " <div class=\"func\"><b>%s</b></div>\n", fun); - fprintf (fid, " <div class=\"ftext\">Not implemented.</div>\n\n"); - endif - endfor - endfor - - fprintf (fid, "\n%s\n", footer); - fclose (fid); - endif - - ################################################ - ## Write function data for alphabetical lists ## - ################################################ - if (isfield (options, "include_alpha") && options.include_alpha) - for letter = "a":"z" - [name_filename, desc_filename] = get_alpha_database (outdir, desc.name, letter); - name_fid = fopen (name_filename, "w"); - desc_fid = fopen (desc_filename, "w"); - if (name_fid == -1 || desc_fid == -1) - error ("generate_package_html: could not open alphabet database for writing"); - endif - - for k = 1:num_categories - F = desc.provides {k}.functions; - for l = 1:length (F) - fun = F {l}; - if (implemented {k}{l} && lower (fun (1)) == letter) - fs = first_sentences {k}{l}; - - fprintf (name_fid, "%s\n", fun); - fprintf (desc_fid, "%s\n", fs); - endif - endfor - endfor - - fclose (name_fid); - fclose (desc_fid); - endfor - endif - - ##################################################### - ## Write short description for forge overview page ## - ##################################################### - - if (isfield (options, "include_package_list_item") && options.include_package_list_item) - pkg_list_item_filename = get_pkg_list_item_filename (desc.name, outdir); - - text = strrep (options.package_list_item, "%name", desc.name); - text = strrep (text, "%version", desc.version); - text = strrep (text, "%extension", "tar.gz"); - text = strrep (text, "%shortdescription", desc.description); - - fid = fopen (pkg_list_item_filename, "w"); - if (fid > 0) - fprintf (fid, text); - fclose (fid); - else - error ("generate_package_html: unable to open file %s.", pkg_list_item_filename); - endif - endif - - ###################### - ## Write index file ## - ###################### - if (isfield (options, "include_package_page") && options.include_package_page) - ## Get detailed information about the package - all_list = pkg ("list"); - list = []; - for k = 1:length (all_list) - if (strcmp (all_list {k}.name, packname)) - list = all_list {k}; - endif - endfor - if (isempty (list)) - error ("generate_package_html: couldn't locate package '%s'", packname); - endif - - ## Open output file - index_filename = "index.html"; - - fid = fopen (fullfile (packdir, index_filename), "w"); - if (fid < 0) - error ("generate_package_html: couldn't open index file for writing"); - endif - - ## Write output - [header, title, footer] = get_index_header_title_and_footer (options, desc.name, "../"); - - fprintf (fid, "%s\n", header); - fprintf (fid, "<h2 class=\"tbdesc\">%s</h2>\n\n", desc.name); - - fprintf (fid, "<table>\n"); - fprintf (fid, "<tr><td rowspan=\"2\" class=\"box_table\">\n"); - fprintf (fid, "<div class=\"package_box\">\n"); - fprintf (fid, " <div class=\"package_box_header\"></div>\n"); - fprintf (fid, " <div class=\"package_box_contents\">\n"); - fprintf (fid, " <table>\n"); - fprintf (fid, " <tr><td class=\"package_table\">Package Version:</td><td>%s</td></tr>\n", - list.version); - fprintf (fid, " <tr><td class=\"package_table\">Last Release Date:</td><td>%s</td></tr>\n", - list.date); - fprintf (fid, " <tr><td class=\"package_table\">Package Author:</td><td>%s</td></tr>\n", - list.author); - fprintf (fid, " <tr><td class=\"package_table\">Package Maintainer:</td><td>%s</td></tr>\n", - list.maintainer); - fprintf (fid, " <tr><td class=\"package_table\">License:</td><td><a href=\"COPYING.html\">"); - if (isfield (list, "license")) - fprintf (fid, "%s</a></td></tr>\n", list.license); - else - fprintf (fid, "Read license</a></td></tr>\n"); - endif - fprintf (fid, " </table>\n"); - fprintf (fid, " </div>\n"); - fprintf (fid, "</div>\n"); - fprintf (fid, "</td>\n\n"); - - fprintf (fid, "<td>\n"); - if (isfield (options, "download_link")) - fprintf (fid, "<div class=\"download_package\">\n"); - fprintf (fid, " <table><tr><td>\n"); - fprintf (fid, " <img src=\"../download.png\"/>\n"); - fprintf (fid, " </td><td>\n"); - link = strrep (options.download_link, "%name", desc.name); - link = strrep (link, "%version", desc.version); - fprintf (fid, " <a href=\"%s\"\n", link); - fprintf (fid, " class=\"download_link\">\n"); - fprintf (fid, " Download Package\n"); - fprintf (fid, " </a><br>\n"); - fprintf (fid, " <a href=\"http://sourceforge.net/projects/octave/files/\""); - fprintf (fid, " class=\"older_versions_download\">(older versions)</a>\n"); - fprintf (fid, " </td></tr></table>\n"); - fprintf (fid, "</div>\n"); - endif - fprintf (fid, "</td></tr>\n"); - fprintf (fid, "<tr><td>\n"); - fprintf (fid, "<div class=\"package_function_reference\">\n"); - fprintf (fid, " <table><tr><td>\n"); - fprintf (fid, " <img src=\"../doc.png\"/>\n"); - fprintf (fid, " </td><td>\n"); - fprintf (fid, " <a href=\"%s\" class=\"function_reference_link\">\n", overview_filename); - fprintf (fid, " Function Reference\n"); - fprintf (fid, " </a>\n"); - fprintf (fid, " </td></tr></table>\n"); - fprintf (fid, "</div>\n"); - fprintf (fid, "</td></tr>\n"); - fprintf (fid, "</table>\n\n"); - - fprintf (fid, "<h3>Description</h3>\n"); - fprintf (fid, " <div id=\"description_box\">\n") - fprintf (fid, list.description); - fprintf (fid, " </div>\n\n") - - fprintf (fid, "<h3>Details</h3>\n"); - fprintf (fid, " <table id=\"extra_package_table\">\n"); - - if (isfield (list, "depends")) - fprintf (fid, " <tr><td>Dependencies: </td><td>\n"); - for k = 1:length (list.depends) - p = list.depends {k}.package; - if (isfield (list.depends {k}, "operator") && isfield (list.depends {k}, "version")) - o = list.depends {k}.operator; - v = list.depends {k}.version; - vt = sprintf ("(%s %s) ", o, v); - else - vt = ""; - endif - - if (strcmpi (p, "octave")) - fprintf (fid, "<a href=\"http://www.octave.org\">Octave</a> "); - else - fprintf (fid, "<a href=\"../%s/index.html\">%s</a> ", p, p); - endif - fprintf (fid, vt); - endfor - fprintf (fid, "</td></tr>\n"); - endif - - if (isfield (list, "buildrequires")) - fprintf (fid, " <tr><td>Build Dependencies:</td><td>%s</td></tr>\n", list.buildrequires); - endif - - if (isfield (list, "autoload")) - if (list.autoload) - a = "Yes"; - else - a = "No"; - endif - fprintf (fid, " <tr><td>Autoload:</td><td>%s</td></tr>\n", a); - endif - - fprintf (fid, " </table>\n\n"); - - fprintf (fid, "\n%s\n", footer); - fclose (fid); - endif - - ###################### - ## Write COPYING file ## - ###################### - if (isfield (options, "include_package_license") && options.include_package_license) - ## Get detailed information about the package - all_list = pkg ("list"); - list = []; - for k = 1:length (all_list) - if (strcmp (all_list {k}.name, packname)) - list = all_list {k}; - endif - endfor - if (isempty (list)) - error ("generate_package_html: couldn't locate package '%s'", packname); - endif - - ## Read license - filename = fullfile (list.dir, "packinfo", "COPYING"); - fid = fopen (filename, "r"); - if (fid < 0) - error ("generate_package_html: couldn't open license for reading"); - endif - contents = char (fread (fid).'); - fclose (fid); - - ## Open output file - copying_filename = "COPYING.html"; - - fid = fopen (fullfile (packdir, copying_filename), "w"); - if (fid < 0) - error ("generate_package_html: couldn't open COPYING file for writing"); - endif - - ## Write output - [header, title, footer] = get_index_header_title_and_footer (options, desc.name, "../"); - - fprintf (fid, "%s\n", header); - fprintf (fid, "<h2 class=\"tbdesc\">License for '%s' Package</h2>\n\n", desc.name); - fprintf (fid, "<p><a href=\"index.html\">Return to the '%s' package</a></p>\n\n", desc.name); - - fprintf (fid, "<pre>%s</pre>\n\n", contents); - - fprintf (fid, "\n%s\n", footer); - fclose (fid); - endif -endfunction - Copied: trunk/octave-forge/extra/generate_latex/inst/generate_package_latex.m (from rev 9788, trunk/octave-forge/extra/generate_html/inst/generate_package_html.m) =================================================================== --- trunk/octave-forge/extra/generate_latex/inst/generate_package_latex.m (rev 0) +++ trunk/octave-forge/extra/generate_latex/inst/generate_package_latex.m 2012-03-25 22:57:18 UTC (rev 10060) @@ -0,0 +1,287 @@ +## Copyright (C) 2012 Carlo de Falco +## Copyright (C) 2008 Soren Hauberg +## +## 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 3 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; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} generate_package_latex (@var{name}, @var{outdir}, @var{options}) +## Generate @t{LaTeX} documentation for a package. +## +## The function reads information about package @var{name} using the +## package system. This is then used to generate a bunch of +## @t{LaTeX} files; one for each function in the package, and one file including them +## all. The files are all placed in the directory @var{outdir}, which defaults +## to the current directory. The @var{options} structure is used to control +## the design of the file. +## +## As an example, the following code generates the manual for the @t{image} +## package. +## +## @example +## options = get_latex_options ("default"); +## generate_package_latex ("image", "image_latex", options); +## @end example +## +## The resulting files will be available in the @t{"image_latex"} directory. The +## main fail will be called @t{"image_html/manual.tex"}. +## +## As a convenience, if @var{options} is a string, a structure will +## be generated by calling @code{get_html_options}. This means the above +## example can be reduced to the following. +## +## @example +## generate_package_latex ("image", "image_latex", "default"); +## @end example +## +## It should be noted that the function only works for installed packages. +## @seealso{get_latex_options} +## @end deftypefn + +function generate_package_latex (name = [], outdir = "latexdocs", options = "default") + + ## Check input + if (isempty (name)) + list = pkg ("list"); + for k = 1:length (list) + generate_package_latex (list {k}.name, outdir, options); + endfor + return; + elseif (isstruct (name)) + desc = name; + if (isfield (name, "name")) + packname = desc.name; + else + packname = ""; + endif + elseif (ischar (name)) + packname = name; + pkg ("load", name); + desc = pkg ("describe", name) {1}; + else + error (["generate_package_latex: first input must either be the name of a ", ... + "package, or a structure giving its description."]); + endif + + if (isempty (outdir)) + outdir = packname; + elseif (! ischar (outdir)) + error ("generate_package_latex: second input argument must be a string"); + endif + + ## Create output directory if needed + if (! exist (outdir, "dir")) + mkdir (outdir); + endif + + packdir = fullfile (outdir, packname); + if (! exist (packdir, "dir")) + mkdir (packdir); + endif + + [local_fundir, fundir] = mk_function_dir (packdir, packname, options); + + ## If options is a string, call get_latex_options + if (ischar (options)) + options = get_latex_options (options); + elseif (! isstruct (options)) + error ("generate_package_latex: third input argument must be a string or a structure"); + endif + + ################################################### + ## Generate latex pages for individual functions ## + ################################################### + options.footer = strrep (options.footer, "@package", packname); + num_categories = length (desc.provides); + anchors = implemented = cell (1, num_categories); + + for k = 1:num_categories + F = desc.provides {k}.functions; + category = desc.provides {k}.category; + anchors {k} = strrep (category, " ", ""); # anchor names + + ## For each function in category + num_functions = length (F); + implemented {k} = cell (1, num_functions); + for l = 1:num_functions + fun = F {l}; + if (any (fun == filesep ())) + at_dir = fileparts (fun); + mkdir (fullfile (fundir, at_dir)); + r = "../../../"; + else + r = "../../"; + endif + outname = fullfile (fundir, sprintf ("%s.tex", fun)); +% try + latex_help_text (fun, outname, options, r); + implemented {k}{l} = true; +% catch +% warning ("marking '%s' as not implemented", fun); +% implemented {k}{l} = false; +% end_try_catch + endfor + endfor + + ######################### + ## Write main file ## + ######################### + first_sentences = cell (1, num_categories); + main_filename = get_main_filename (options, desc.name); + + fid = fopen (fullfile (packdir, main_filename), "w"); + if (fid < 0) + error ("generate_package_latex: couldn't open main file for writing"); + endif + + [header, title, footer] = get_main_header_title_and_footer (options, desc.name, "../"); + + fprintf (fid, "%s\n", header); + fprintf (fid, "\\title{%s}\n", desc.name); + fprintf (fid, "\\begin{document}\n"); + fprintf (fid, "\\maketitle\n"); + if (options.include_toc) + fprintf (fid, "\\tableofcontents\n"); + endif + + + ###################### + ## Write file intro ## + ###################### + + ## Get detailed information about the package + all_list = pkg ("list"); + list = []; + for k = 1:length (all_list) + if (strcmp (all_list {k}.name, packname)) + list = all_list {k}; + endif + endfor + if (isempty (list)) + error ("generate_package_latex: couldn't locate package '%s'", packname); + endif + + ## Write output + fprintf (fid, "%s\n", options.intro_pre); + fprintf (fid, "%s%s%s\n", options.name_pre, __ec__ (desc.name), options.name_post); + fprintf (fid, "%s%s%s\n", options.desc_pre, __ec__ (desc.description), options.desc_post); + fprintf (fid, "%s%s%s\n", options.version_pre, __ec__ (list.version), options.version_post); + fprintf (fid, "%s%s%s\n", options.date_pre, __ec__ (list.date), options.date_post); + fprintf (fid, "%s%s%s\n", options.author_pre, __ec__ (list.author), options.author_post); + fprintf (fid, "%s%s%s\n", options.maintainer_pre, __ec__ (list.maintainer), options.maintainer_post); + fprintf (fid, "%s%s%s\n", options.license_pre, __ec__ (list.license), options.license_post); + if (isfield (list, "depends")) + fprintf (fid, "%s\n", options.deps_pre); + for k = 1:length (list.depends) + vt = __ec__ (list.depends {k}.package); + if (isfield (list.depends {k}, "operator") && isfield (list.depends {k}, "version")) + o = list.depends {k}.operator; + v = list.depends {k}.version; + vt = sprintf ("%s ($%s$ %s), ", vt, o, v); + else + vt = ""; + endif + + fprintf (fid, vt); + endfor + fprintf (fid, "%s\n", options.deps_sep); + endif + fprintf (fid, "%s\n", options.deps_post); + + if (isfield (list, "buildrequires")) + fprintf (fid, "%s%s%s\n", options.buildreq_pre, list.buildrequires, options.buildreq_post); + endif + + if (isfield (list, "autoload")) + if (list.autoload) + a = "Yes"; + else + a = "No"; + endif + fprintf (fid, "%s%s%s\n", options.autoload_pre, a, options.autoload_post); + endif + + fprintf (fid, "%s\n", options.intro_post); + + + ## Generate function list by category + for k = 1:num_categories + F = desc.provides {k}.functions; + category = desc.provides {k}.category; + first_sentences {k} = cell (1, length (F)); + + ## For each function in category + for l = 1:length (F) + fun = F {l}; + if (implemented {k}{l}) + first_sentences {k}{l} = get_first_help_sentence (fun, 200); + first_sentences {k}{l} = strrep (first_sentences {k}{l}, "\n", " "); + + link = sprintf ('%s%s%s.tex', local_fundir, filesep (), fun); + fprintf (fid, "%s%s%s\n", options.function_name_pre, options.function_name_mangle (fun), options.function_name_post); + fprintf (fid, "\\input{%s}\n", link); + else + fprintf (fid, "%s%s%s\n", options.function_name_pre, options.function_name_mangle (fun), options.function_name_post); + fprintf (fid, "Not Implemnted.\n", fun); + endif + endfor + endfor + + if (isfield (options, "include_package_license") && options.include_package_license) + copying_filename = "COPYING.tex"; + fprintf (fid, "\\input{%s}\n", copying_filename); + endif + + fprintf (fid, "\n%s\n\\end{document}", footer); + fclose (fid); + + ######################## + ## Write COPYING file ## + ######################## + + if (isfield (options, "include_package_license") && options.include_package_license) + ## Get detailed information about the package + all_list = pkg ("list"); + list = []; + for k = 1:length (all_list) + if (strcmp (all_list {k}.name, packname)) + list = all_list {k}; + endif + endfor + if (isempty (list)) + error ("generate_package_latex: couldn't locate package '%s'", packname); + endif + + ## Read license + filename = fullfile (list.dir, "packinfo", "COPYING"); + fid = fopen (filename, "r"); + if (fid < 0) + error ("generate_package_latex: couldn't open license for reading"); + endif + contents = char (fread (fid).'); + fclose (fid); + + ## Open output file + fid = fopen (fullfile (packdir, copying_filename), "w"); + if (fid < 0) + error ("generate_package_latex: couldn't open COPYING file for writing"); + endif + + fprintf (fid, "\n%s\n", options.license_file_pre); + fprintf (fid, "%s\n\n", contents); + fprintf (fid, "\n%s\n", options.license_file_post); + fclose (fid); + endif +endfunction + Deleted: trunk/octave-forge/extra/generate_latex/inst/get_html_options.m =================================================================== --- trunk/octave-forge/extra/generate_html/inst/get_html_options.m 2012-03-08 16:23:48 UTC (rev 9788) +++ trunk/octave-forge/extra/generate_latex/inst/get_html_options.m 2012-03-25 22:57:18 UTC (rev 10060) @@ -1,204 +0,0 @@ -## Copyright (C) 2008 Soren Hauberg -## -## 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 3 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; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{options} =} get_html_options (@var{project_name}) -## Returns a structure containing design options for various project web sites. -## -## Given a string @var{project_name}, the function returns a structure containing -## various types of information for generating web pages for the specified project. -## Currently, the accepted values of @var{project_name} are -## -## @table @t -## @item "octave-forge" -## Design corresponding to the pages at @t{http://octave.sf.net}. -## -## @item "octave" -## Design corresponding to the pages at @t{http://octave.org}. The pages are -## meant to be processed with the @code{m4} preprocessor, using the macros for -## the site. -## -## @item "docbrowser" -## Design corresponding to the pages in the documentation browser. -## @end table -## @seealso{generate_package_html, html_help_text} -## @end deftypefn - -function options = get_html_options (project_name) - ## Check input - if (nargin == 0) - error ("get_html_options: not enough input arguments"); - endif - - if (!ischar (project_name)) - error ("get_html_options: first input argument must be a string"); - endif - - ## Generate options depending on project - switch (lower (project_name)) - case "octave-forge" - ## Basic HTML header - hh = "\ -<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\ - \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\ -<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n\ - <head>\n\ - <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" />\n\ - <meta name=\"date\" content=\"%date\"/>\n\ - <meta name=\"author\" content=\"The Octave-Forge Community\" />\n\ - <meta name=\"description\" content=\"Octave-Forge is a collection of packages\ - providing extra functionality for GNU Octave.\" />\n\ - <meta name=\"keywords\" lang=\"en\" content=\"Octave-Forge, Octave, extra packages\" />\n\ - <title>%title</title>\n\ - <link rel=\"stylesheet\" type=\"text/css\" href=\"%root%css\" />\n\ - <script src=\"%rootfixed.js\" type=\"text/javascript\"></script>\n\ - <script src=\"%rootjavascript.js\" type=\"text/javascript\"></script>\n\ - <link rel=\"shortcut icon\" href=\"%rootfavicon.ico\" />\n\ - </head>\n\ - <body %body_command>\n\ - <div id=\"top-menu\" class=\"menu\">\n\ - <table class=\"menu\">\n\ - <tr>\n\ - <td style=\"width: 90px;\" class=\"menu\" rowspan=\"2\">\n\ - <a name=\"top\">\n\ - <img src=\"%rootoct.png\" alt=\"Octave logo\" />\n\ - </a>\n\ - </td>\n\ - <td class=\"menu\" style=\"padding-top: 0.9em;\">\n\ - <big class=\"menu\">Octave-Forge</big><small class=\"menu\"> - Extra packages for GNU Octave</small>\n\ - </td>\n\ - </tr>\n\ - <tr>\n\ - <td class=\"menu\">\n\ -\n\ - <a href=\"%rootindex.html\" class=\"menu\">Home</a> ·\n\ - <a href=\"%rootpackages.php\" class=\"menu\">Packages</a> ·\n\ - <a href=\"%rootdevelopers.html\" class=\"menu\">Developers</a> ·\n\ - <a href=\"%rootdocs.html\" class=\"menu\">Documentation</a> ·\n\ - <a href=\"%rootFAQ.html\" class=\"menu\">FAQ</a> ·\n\ - <a href=\"%rootbugs.html\" class=\"menu\">Bugs</a> ·\n\ - <a href=\"%rootarchive.html\" class=\"menu\">Mailing Lists</a> ·\n\ - <a href=\"%rootlinks.html\" class=\"menu\">Links</a> ·\n\ - <a href=\"http://sourceforge.net/svn/?group_id=2888\" class=\"menu\">SVN</a>\n\ -\n\ - </td>\n\ - </tr>\n\ - </table>\n\ - </div>\n\ -<div id=\"left-menu\">\n\ - <h3>Navigation</h3>\n\ - <p class=\"left-menu\"><a class=\"left-menu-link\" href=\"%rootoperators.html\">Operators and Keywords</a></p>\n\ - <p class=\"left-menu\"><a class=\"left-menu-link\" href=\"%rootfunction_list.html\">Function List:</a>\n\ - <ul class=\"left-menu-list\">\n\ - <li class=\"left-menu-list\">\n\ - <a class=\"left-menu-link\" href=\"%rootoctave/overview.html\">» Octave core</a>\n\ - </li>\n\ - <li class=\"left-menu-list\">\n\ - <a class=\"left-menu-link\" href=\"%rootfunctions_by_package.php\">» by package</a>\n\ - </li>\n\ - <li class=\"left-menu-list\">\n\ - <a class=\"left-menu-link\" href=\"%rootfunctions_by_alpha.php\">» alphabetical</a>\n\ - </li>\n\ - </ul>\n\ - </p>\n\ - <p class=\"left-menu\"><a class=\"left-menu-link\" href=\"%rootdoxygen/html\">C++ API</a></p>\n\ -</div>\n\ -<div id=\"doccontent\">\n"; - - ## CSS - options.css = "octave-forge.css"; - - ## Options for alphabetical lists - options.include_alpha = true; - - ## Options for individual function pages - options.pack_body_cmd = 'onload="javascript:fix_top_menu (); javascript:show_left_menu ();"'; - options.header = strrep (hh, "%date", date ()); - options.footer = "<p>Package: <a href=\"../index.html\">%package</a></p>\n<div id=\"sf_logo\">\n\ - <a href=\"http://sourceforge.net\">\ - <img src=\"http://sourceforge.net/sflogo.php?group_id=2888&type=1\"\ - width=\"88\" height=\"31\" style=\"border: 0;\" alt=\"SourceForge.net Logo\"/>\ - </a>\n</div>\n</div>\n</body>\n</html>\n"; - options.title = "Function Reference: %name"; - options.include_demos = true; - options.seealso = @octave_forge_seealso; - - ## Options for overview page - options.include_overview = true; - #options.overview_header = strrep (strrep (hh, "%date", date ()), "%body_command", ""); - options.manual_body_cmd = 'onload="javascript:fix_top_menu (); javascript:manual_menu ();"'; - - ## Options for package list page - options.include_package_list_item = true; - options.package_list_item = ... -"<div class=\"package\" id=\"%name\">\n\ -<table class=\"package\"><tr>\n\ -<td><b><a href=\"javascript:unfold('%name');\" class=\"package_head_link\">\n\ -<img src=\"show.png\" id=\"%name_im\" alt=\"show/hide\" style=\"padding-right: 0.5em; border: none;\"/> %name </a></b></td>\n\ -<td style=\"text-align: right;\">» <a href=\"./%name/index.html\" class=\"package_link\">details</a> |\n\ -<a class=\"package_link\" href=\"http://downloads.sourceforge.net/octave/%name-%version.%extension?download\">download</a></td>\n\ -</tr></table>\n\ -<p id=\"%name_detailed\" style=\"display: none;\"> %shortdescription </p>\n\ -</div>\n"; - - ## Options for index package - options.index_title = "The '%name' Package"; - options.download_link = "http://downloads.sourceforge.net/octave/%name-%version.tar.gz?download"; - options.include_package_page = true; - options.include_package_license = true; - options.index_body_command = "onload=\"javascript:fix_top_menu ();\""; - - case "octave" - options.header = "__HEADER__(`%title')"; - options.footer = "__OCTAVE_TRAILER__"; - options.title = "Function Reference: %name"; - options.include_overview = true; - - case "docbrowser" - ## Basic HTML header - hh = "\ -<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\ - \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\ -<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n\ - <head>\n\ - <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" />\n\ - <meta name=\"date\" content=\"%date\"/>\n\ - <meta name=\"author\" content=\"The Octave Community\" />\n\ - <title>%title</title>\n\ - <link rel=\"stylesheet\" type=\"text/css\" href=\"%css\" />\n\ - </head>\n\ -<body>\n\ -<div id=\"top\">Function Reference</div>\n\ -<div id=\"doccontent\">\n"; - hh = strrep (hh, "%date", date ()); - - ## Options for individual function pages - css = "doc.css"; - options.header = strrep (hh, "%css", css); - options.footer = "</div>\n</body>\n</html>\n"; - options.title = "Function: %name"; - options.include_demos = true; - - ## Options for overview page - options.include_overview = true; - options.overview_header = strrep (hh, "%css", sprintf ("../%s", css)); - options.overview_title = "Overview: %name"; - - otherwise - error ("get_html_options: unknown project name: %s", project_name); - endswitch - -endfunction Copied: trunk/octave-forge/extra/generate_latex/inst/get_latex_options.m (from rev 9788, trunk/octave-forge/extra/generate_html/inst/get_html_options.m) =================================================================== --- trunk/octave-forge/extra/generate_latex/inst/get_latex_options.m (rev 0) +++ trunk/octave-forge/extra/generate_latex/inst/get_latex_options.m 2012-03-25 22:57:18 UTC (rev 10060) @@ -0,0 +1,186 @@ +## Copyright (C) 2012 Carlo de Falco +## Copyright (C) 2008 Soren Hauberg +## +## 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 3 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; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{options} =} get_latex_options (@var{document_type}) +## Returns a structure containing design options for a latex manual. +## +## Given a string @var{document_type}, the function returns a structure containing +## various types of information for generating latex manual for the specified document type. +## Currently, the accepted values of @var{document_type} are +## +## @table @minus +## @item "amsart_a5" +## amsart document class on a5 paper. +## @item "article_a4" +## amsart document class on a5 paper. +## @end table +## @seealso{generate_package_latex, latex_help_text} +## @end deftypefn + +function options = get_latex_options (project_name) + ## Check input + if (nargin == 0) + error ("get_latex_options: not enough input arguments"); + endif + + if (!ischar (project_name)) + error ("get_latex_options: first input argument must be a string"); + endif + + ## Generate options depending on project + switch (lower (project_name)) + case "amsart_a5" + options = amsart_a5_options (); + case "article_a4" + options = article_a4_options (); + otherwise + error ("get_latex_options: unknown project name: %s", project_name); + endswitch + +endfunction + + +function options = amsart_a5_options () + + ## Basic latex header + hh = "\ +\\documentclass{amsart} \n\ +\\usepackage{geometry} \n\ +\\geometry{a5paper} \n\ +\\usepackage{graphicx} \n\ +\\usepackage{amssymb} \n\ +\\usepackage{epstopdf} \n\ +\\usepackage{cprotect,fancyvrb} \n\ +\\usepackage{float} \n\ +\\floatstyle{ruled} \n\ +\\newfloat{demo}{thp}{dem} \n\ +\\floatname{demo}{Demo} \n\ +\\newfloat{demoout}{thp}{deo} \n\ +\\floatname{demoout}{Demo Output} \n\ +\n"; + + options.function_name_pre = "\\cprotect\\section{\\verb|"; + options.function_name_mangle = @(x) x; + options.function_name_post = "|}\n"; + + ## Options for alphabetical lists + options.intro_pre = "\\section{Package Description}\n"; + options.intro_post = "%end package description\n"; + options.name_pre = "{\\bf Name: } "; + options.name_post = "\\\\ \n"; + options.desc_pre = "{\\bf Description: } \\\\\n"; + options.desc_post = "\\\\\n"; + options.version_pre = "{\\bf Version: } "; + options.version_post = "\\\\ \n"; + options.date_pre = "{\\bf Release Date: } "; + options.date_post = "\\\\ \n"; + options.author_pre = "{\\bf Author: } "; + options.author_post = "\\\\ \n"; + options.maintainer_pre = "{\\bf Maintainer: } "; + options.maintainer_post = "\\\\ \n"; + options.license_pre = "{\\bf License: } "; + options.license_post = "\\\\ \n"; + options.deps_pre = "{\\bf Depends on: } \\\\ \n"; + options.deps_post = "\\null \n"; + options.deps_sep = "\\\\ \n"; + options.buildreq_pre = "{\\bf Build dependencies: } \\\\ \n"; + options.buildreq_post = "\\\\ \n"; + options.autoload_pre = "{\\bf Autoload: } \n"; + options.autoload_post = "\\\\ \n"; + + ## Options for individual function pages + options.header = "\\begin{SaveVerbatim}{VerbBox}\n"; + options.footer = "\\end{SaveVerbatim}\n\\resizebox{.9\\linewidth}{!}{\\BUseVerbatim{VerbBox}}"; + options.include_demos = true; + + ## Options for overview page + options.main_header = sprintf ("%s", hh); + options.main_footer = " "; + options.include_toc = true; + + ## Options for COPYING file + options.include_package_license = true; + options.license_file_pre = "\\begin{Verbatim}"; + options.license_file_post = "\\end{Verbatim}\n\\null\n"; + +endfunction + +function options = article_a4_options () + + ## Basic latex header + hh = "\ +\\documentclass[10pt]{article} \n\ +\\usepackage{geometry} \n\ +\\geometry{a4paper} \n\ +\\usepackage{graphicx} \n\ +\\usepackage{amssymb} \n\ +\\usepackage{epstopdf} \n\ +\\usepackage{cprotect} \n\ +\\usepackage{float} \n\ +\\floatstyle{plain} \n\ +\\newfloat{demo}{thp}{dem} \n\ +\\floatname{demo}{Demo} \n\ +\\newfloat{demoout}{thp}{deo} \n\ +\\floatname{demoout}{Demo Output} \n\ +\n"; + + options.function_name_pre = "\\section{"; + options.function_name_mangle = @(x) __ec__ (x); + options.function_name_post = "}\n"; + + ## Options for alphabetical lists + options.intro_pre = "\\section{Package Description}\n"; + options.intro_post = "%end package description\n"; + options.name_pre = "{\\bf Name: } "; + options.name_post = "\\\\ \n"; + options.desc_pre = "{\\bf Description: } \\\\\n"; + opti... [truncated message content] |