[gtk-doc] Support highlight options



commit d5b16edb73d4609b33bc7833991026bea7f0236d
Author: Dexter Chua <dalcde yahoo com hk>
Date:   Mon May 25 08:48:06 2015 +0100

    Support highlight options
    
    This commit allows gtk-doc users to supply a --src-lang option to
    gtkdoc-fixxref so that the syntax highlight will be performed in the
    correct language. The option is global, ie. applies to the whole project
    built, as opposed to individual files. The default option is "c", which
    is what used to be hardcoded in the gtkdoc-fixxref, so backwards
    compatibility is maintained.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749816

 configure.ac      |    8 ++++----
 gtkdoc-fixxref.in |   15 ++++++++++++---
 2 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8cebc17..abca744 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,11 +110,11 @@ HIGHLIGHT_OPTIONS=""
 if test "$with_highlight" = "auto"; then
        AC_PATH_PROG([HIGHLIGHT], [source-highlight])
        if test -n "$HIGHLIGHT"; then
-               HIGHLIGHT_OPTIONS="-t4 -sc -cstyle.css --no-doc -i"
+               HIGHLIGHT_OPTIONS="-t4 -s\$SRC_LANG -cstyle.css --no-doc -i"
        else
                AC_PATH_PROG([HIGHLIGHT], [highlight])
                if test -n "$HIGHLIGHT"; then
-                       HIGHLIGHT_OPTIONS="--out-format=xhtml -f --class-name=gtkdoc "
+                       HIGHLIGHT_OPTIONS="--syntax=\$SRC_LANG --out-format=xhtml -f --class-name=gtkdoc "
                else
                        AC_PATH_PROG([HIGHLIGHT], [vim])
                        if test -n "$HIGHLIGHT"; then
@@ -135,8 +135,8 @@ else
        fi
 
        case $with_highlight in
-               source-highlight) HIGHLIGHT_OPTIONS="-t4 -sc -cstyle.css --no-doc -i";;
-               highlight) HIGHLIGHT_OPTIONS="--out-format=xhtml -f --class-name=gtkdoc ";;
+               source-highlight) HIGHLIGHT_OPTIONS="-t4 -s\$SRC_LANG -cstyle.css --no-doc -i";;
+               highlight) HIGHLIGHT_OPTIONS="--syntax=\$SRC_LANG --out-format=xhtml -f --class-name=gtkdoc 
";;
                vim)
                        AC_MSG_CHECKING([whether vim has +syntax feature])
                        if $HIGHLIGHT --version | grep '+syntax' >/dev/null; then
diff --git a/gtkdoc-fixxref.in b/gtkdoc-fixxref.in
index a6256dd..774970c 100755
--- a/gtkdoc-fixxref.in
+++ b/gtkdoc-fixxref.in
@@ -40,15 +40,17 @@ my $HTML_DIR = "";
 my @EXTRA_DIRS;
 my $PRINT_VERSION;
 my $PRINT_HELP;
+my $SRC_LANG;
 
 my %optctl = ('module' => \$MODULE,
               'module-dir' => \$MODULE_DIR,
               'html-dir' => \$HTML_DIR,
               'extra-dir' => \ EXTRA_DIRS,
               'version' => \$PRINT_VERSION,
-              'help' => \$PRINT_HELP);
+              'help' => \$PRINT_HELP,
+              'src-lang' => \$SRC_LANG);
 GetOptions(\%optctl, "module=s", "module-dir=s", "html-dir:s", "extra-dir=s@",
-        "version", "help");
+        "src-lang=s", "version", "help");
 
 if ($PRINT_VERSION) {
     print "@VERSION \n";
@@ -66,12 +68,19 @@ gtkdoc-fixxref version @VERSION@ - fix cross references in html files
 --extra-dir=EXTRA_DIR   Directories to recursively scan for indices (index.sgml)
                         in addition to HTML_DIR
                         May be used more than once for multiple directories
+--src-lang=SRC_LANG     Programing language used for syntax highlighting. The
+                        available languages depend on the source source
+                        highlighter you use.
 --version               Print the version of this program
 --help                  Print this help
 EOF
     exit 0;
 }
 
+if (!$SRC_LANG) {
+    $SRC_LANG="c"
+}
+
 # This contains all the entities and their relative URLs.
 my %Links;
 
@@ -467,7 +476,7 @@ sub HighlightSourceVim {
     close (NEWFILE);
 
     # format source
-    system "echo 'let html_number_lines=0|let html_use_css=1|let html_use_xhtml=1|syn on|e 
$temp_source_file|run! syntax/2html.vim|w! $temp_source_file.html|qa!' | @HIGHLIGHT@ -n -e -u NONE -T xterm 
/dev/null";
+    system "echo 'let html_number_lines=0|let html_use_css=1|let html_use_xhtml=1|e $temp_source_file|syn 
on|set syntax=$SRC_LANG|run! syntax/2html.vim|w! $temp_source_file.html|qa!' | @HIGHLIGHT@ -n -e -u NONE -T 
xterm >/dev/null";
 
     my $highlighted_source;
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]