changeset 9014:71fca0fc2436

save source file names for functions as comments in .texi files
author John W. Eaton <jwe@octave.org>
date Wed, 25 Mar 2009 12:54:17 -0400
parents 3b1908b58662
children 06cebb6c5dde
files doc/ChangeLog doc/interpreter/munge-texi.cc scripts/ChangeLog scripts/gethelp.cc scripts/mkdoc src/ChangeLog src/Makefile.in src/mkbuiltins src/mkgendoc
diffstat 9 files changed, 73 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog	Wed Mar 25 14:29:50 2009 +0100
+++ b/doc/ChangeLog	Wed Mar 25 12:54:17 2009 -0400
@@ -1,3 +1,8 @@
+2009-03-25  John W. Eaton  <jwe@octave.org>
+
+	* interpreter/munge-texi.cc (process_texi_input_file):
+	Copy leading comment with file name info to output.
+
 2009-03-09  John W. Eaton  <jwe@octave.org>
 
 	* interpreter/Makefile.in (DISTFILES): Use doc-cache instead of
--- a/doc/interpreter/munge-texi.cc	Wed Mar 25 14:29:50 2009 +0100
+++ b/doc/interpreter/munge-texi.cc	Wed Mar 25 12:54:17 2009 -0400
@@ -245,7 +245,23 @@
 		    {
 		      std::string doc_string = help_text[symbol_name];
 
+		      size_t len = doc_string.length ();
+
 		      int j = 0;
+
+		      // If there is a leading comment with the file
+		      // name, copy it to the output.
+		      if (len > 1
+			  && doc_string[j] == '@'
+			  && doc_string[j+1] == 'c')
+			{
+			  j = 2;
+			  while (doc_string[j++] != '\n')
+			    /* find eol */;
+
+			  os << doc_string.substr (0, j);
+			}
+
 		      while (doc_string[j] == ' ')
 			j++;
 
--- a/scripts/ChangeLog	Wed Mar 25 14:29:50 2009 +0100
+++ b/scripts/ChangeLog	Wed Mar 25 12:54:17 2009 -0400
@@ -1,3 +1,9 @@
+2009-03-25  John W. Eaton  <jwe@octave.org>
+
+	* mkdoc: Pass full file name to gethelp.
+	* gethelp.cc (main): Handle second argument.  Write comment with
+	full file name to output.
+
 2009-03-24  Ben Abbott <bpabbott@mac.com>
 
 	* plot/gnuplot_drawnow.m: When printing, pass scalar plot_stream
--- a/scripts/gethelp.cc	Wed Mar 25 14:29:50 2009 +0100
+++ b/scripts/gethelp.cc	Wed Mar 25 12:54:17 2009 -0400
@@ -135,20 +135,26 @@
 main (int argc, char **argv)
 {
   std::string name;
+  std::string file_name;
 
-  if (argc != 2)
+  if (argc != 3)
     {
-      std::cerr << "usage: gethelp name\n";
+      std::cerr << "usage: gethelp name file-name\n";
       return 1;
     }
   else
-    name = argv[1];
+    {
+      name = argv[1];
+      file_name = argv[2];
+    }
 
   std::string help_text = extract_help_text ();  
 
   if (! help_text.empty ())
     {
-      std::cout << "" << name << "\n" << help_text;
+      std::cout << "" << name << "\n"
+		<< "@c " << file_name << "\n"
+		<< help_text;
 
       if (help_text[help_text.length () - 1] != '\n')
 	std::cout << "\n";
--- a/scripts/mkdoc	Wed Mar 25 14:29:50 2009 +0100
+++ b/scripts/mkdoc	Wed Mar 25 12:54:17 2009 -0400
@@ -42,15 +42,17 @@
 
 EOF
   $FIND $d -name '*.m' | \
-    $PERL -ne 'm{(.*)/(.*)\.m};
-               for (qx{./gethelp $2 < $_}) {
+    $PERL -n -e 'chop;
+               $f = "$_";
+               m{(.*)/(.*)\.m};
+               for (qx{./gethelp $2 "$f" < "$f"}) {
                  s/^\s+\@/\@/ unless $i_am_in_example;
                  s/^\s+\@group/\@group/;
                  s/^\s+\@end\s+group/\@end\s+group/;
                  $i_am_in_example = 1 if /\s*\@example/;
                  $i_am_in_example = 0 if /\s*\@end\s+example/;
                  print;
-               }'  
+               }'
 else
   echo "gethelp program seems to be missing!" 1>&2
   exit 1
--- a/src/ChangeLog	Wed Mar 25 14:29:50 2009 +0100
+++ b/src/ChangeLog	Wed Mar 25 12:54:17 2009 -0400
@@ -1,3 +1,15 @@
+2009-03-25  John W. Eaton  <jwe@octave.org>
+
+	* Makefile.in (%.df : %.cc): Write source file name to output,
+	wrapped in XDEFUN_FILE_NAME macro.
+	* mkbuiltins: Provide definition for XDEFUN_FILE_NAME.
+	* mkgendoc: Likeiwse.
+	(XDEFUN_DLD_INTERNAL, XDEFUNX_DLD_INTERNAL, XDEFUN_INTERNAL,
+	XDEFCONSTFUN_INTERNAL, XDEFUNX_INTERNAL, XDEFVAR_INTERNAL,
+	XDEFCONST_INTERNAL): Pass file_name to print_doc_string.
+	(print_doc_string): New arg, FILE_NAME.  Print file name as
+	comment.
+
 2009-03-24  John W. Eaton  <jwe@octave.org>
 
 	* ov-class.cc (F__parent_classes__): New function.
--- a/src/Makefile.in	Wed Mar 25 14:29:50 2009 +0100
+++ b/src/Makefile.in	Wed Mar 25 12:54:17 2009 -0400
@@ -40,6 +40,7 @@
 %.df : %.cc
 	@echo making $@ from $<
 	@(echo "// DO NOT EDIT!  Generated automatically by mkdefs." ; \
+	  echo " XDEFUN_FILE_NAME (\"$<\")" ; \
 	  egrep '^(///*|/\*) *PKG_ADD:' $< ; \
 	  $(CXXCPP) $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) -DMAKE_BUILTINS $< \
 	    | $(srcdir)/mkdefs) > $@-t
--- a/src/mkbuiltins	Wed Mar 25 14:29:50 2009 +0100
+++ b/src/mkbuiltins	Wed Mar 25 12:54:17 2009 -0400
@@ -65,6 +65,8 @@
 
 #endif
 
+#define XDEFUN_FILE_NAME(name)
+
 #define XDEFUN_INTERNAL(name, args_name, nargout_name, doc) \
   extern DECLARE_FUN (name, args_name, nargout_name); \
   install_builtin_function (F ## name, #name, doc); \
--- a/src/mkgendoc	Wed Mar 25 14:29:50 2009 +0100
+++ b/src/mkgendoc	Wed Mar 25 12:54:17 2009 -0400
@@ -43,42 +43,47 @@
 #include <iostream>
 #include <string>
 
+#define XDEFUN_FILE_NAME(name) \
+  std::string file_name = name;
+
 #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \
-  print_doc_string (#name, doc);
+  print_doc_string (#name, file_name, doc);
 
 #define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \
-  print_doc_string (name, doc);
+  print_doc_string (name, file_name, doc);
 
 #define XDEFUN_INTERNAL(name, args_name, nargout_name, doc) \
-  print_doc_string (#name, doc);
+  print_doc_string (#name, file_name, doc);
 
 #define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \
-  print_doc_string (#name, doc);
+  print_doc_string (#name, file_name, doc);
 
 #define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \
-  print_doc_string (name, doc);
+  print_doc_string (name, file_name, doc);
 
 #define XDEFALIAS_INTERNAL(alias, name)
 
 #define XDEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \
-  print_doc_string (#name, doc);
+  print_doc_string (#name, file_name, doc);
 
 #define XDEFCONST_INTERNAL(name, defn, doc) \
-  print_doc_string (#name, doc);
+  print_doc_string (#name, file_name, doc);
 
 static void
-print_doc_string (const std::string& name, const std::string& doc)
+print_doc_string (const std::string& name, const std::string& file_name,
+		  const std::string& doc)
 {
   std::cout << "";
 
   size_t len = name.length ();
 
   if (name[0] == '"' && name[len-1] == '"')
-    std::cout << name.substr (1, len-2);
+    std::cout << name.substr (1, len-2) << "\n";
   else
-    std::cout << name;
+    std::cout << name << "\n";
 
-  std::cout << "\n" << doc << "\n";
+  std::cout << "@c " << file_name << "\n"
+	    << doc << "\n";
 }
 
 EOF