r856 - in /trunk/packages/vim-scripts: bin/ bin/dtd2vim debian/TODO.Debian debian/changelog debian/copyright debian/dirs debian/install debian/vim-scripts.pl debian/vim-scripts.status

zack at users.alioth.debian.org zack at users.alioth.debian.org
Sat Jan 20 12:24:59 UTC 2007


Author: zack
Date: Sat Jan 20 13:24:58 2007
New Revision: 856

URL: http://svn.debian.org/wsvn/pkg-vim/?sc=1&rev=856
Log:
added dtd2vim

Added:
    trunk/packages/vim-scripts/bin/
    trunk/packages/vim-scripts/bin/dtd2vim   (with props)
Modified:
    trunk/packages/vim-scripts/debian/TODO.Debian
    trunk/packages/vim-scripts/debian/changelog
    trunk/packages/vim-scripts/debian/copyright
    trunk/packages/vim-scripts/debian/dirs
    trunk/packages/vim-scripts/debian/install
    trunk/packages/vim-scripts/debian/vim-scripts.pl
    trunk/packages/vim-scripts/debian/vim-scripts.status

Added: trunk/packages/vim-scripts/bin/dtd2vim
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/bin/dtd2vim?rev=856&op=file
==============================================================================
--- trunk/packages/vim-scripts/bin/dtd2vim (added)
+++ trunk/packages/vim-scripts/bin/dtd2vim Sat Jan 20 13:24:58 2007
@@ -1,0 +1,198 @@
+#!/usr/bin/perl
+#
+# Author: Mikolaj Machowski ( mikmach AT wp DOT pl )
+# Version: 2.0
+# License: GPL v. 2
+# Date: 25 Apr 2006
+#
+# Script for creation XML data file for Vim7 XML omni-completion from DTDs
+# Requires: perlSGML (tested against 1997Sep18 version)
+
+# USAGE:
+#
+#    dtd2vim <file.dtd> [<dialectname>]
+#
+# This command will create file <file.vim> (remove .dtd extension and add .vim;
+# other extensions will remain intact).
+#
+# <dialectname> (not obligatory) will be part of dictionary name and will be
+# used as argument for :XMLns command (file name - sans extensions) have to be
+# the same.
+#
+# perlSGML and this script doesn't work with multiple files. User has to
+# prepare single DTD file to parse all data.
+#
+# In created file global variable is named g:xmldata_<dialectname>. When second
+# argument wasn't provided 'xxxx' will be used.
+# After that place file in:
+#
+#    ~/.vim/autoload/xml
+#
+# directory. Of course it can be also global directory or other Vim data
+# hierarchy of files. Example for  DocBook 4.4:
+# DTD is in file docbook.dtd, call command with
+#
+#    dtd2vim.pl docbook.dtd docbook44
+#
+# Put file as:
+#   
+#    ~/.vim/autoload/xml/docbook44.vim
+#
+#  Omni-completion for DocBook 4.4 files will be started with:
+#
+#    :XMLns docbook44
+#
+#  command.
+#
+# Potential problems: not always properly detected vimxmlroot.
+#
+# ChangeLog:
+# 1.1 (19 Apr)
+#     - commented out generation of * to mark required attributes - too many
+#     false positives
+#     - skip more DTD keywords: NAME, NUMBER
+
+
+# License:
+#  Copyright (C) 2006 Mikolaj Machowski <mikmach at wp.pl>
+#
+#  This script is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Library General Public
+#  License as published by the Free Software Foundation; either
+#  version 2 of the License, or (at your option) any later version.
+#
+#  This library 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
+#  Library General Public License for more details.
+#
+#  You should have received a copy of the GNU Library General Public License
+#  along with this library; see the file COPYING.LIB.  If not, write to
+#  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+#  Boston, MA 02110-1301, USA.
+
+use SGML::DTD;
+
+if ( $#ARGV < 0 ){
+	print "Script generating XML omni completion data file for Vim7\n";
+	print "USAGE:\n";
+	print "  dtd2vim.pl <filename> [<dialectname>]\n";
+	exit 1;
+}
+
+open (FILE, "@ARGV[0]") or die "$!";
+
+$dtd = new SGML::DTD;
+$dtd->read_dtd(\*FILE);
+
+close FILE;
+
+ at top_elements = $dtd->get_top_elements();
+$tops = join "', '", @top_elements;
+$tops = "'" . $tops . "'";
+
+
+$" = ","; #" Dirty trick: highlighting cant cope with LIST_SEP. var
+ at entities_data = $dtd->get_gen_data_ents("0");
+
+ at entities = $dtd->get_gen_ents("0");
+$ents = join "', '", @entities;
+$ents = "'" . $ents . "'";
+
+$output = @ARGV[0];
+$output =~ s/\.dtd$//;
+$output .= '.vim';
+open (DATA, "> $output") or die "$!";
+
+if (@ARGV > 1){
+	$dialect = @ARGV[1];
+} else {
+	$dialect = 'xxxx';
+}
+
+print DATA "let g:xmldata_$dialect = {\n";
+print DATA "\\ 'vimxmlentities': [$ents],\n";
+print DATA "\\ 'vimxmlroot': [$tops],\n";
+
+# Initialize tag info string
+$taginfo = '';
+
+ at list_of_elements = $dtd->get_elements();
+foreach $element (@list_of_elements) {
+
+	# Get possible childs of current element
+	@element_childs = $dtd->get_base_children($element);
+	@element_childs = (@element_childs, $dtd->get_inc_children($element));
+	@element_nochilds = $dtd->get_exc_children($element);
+	# Remove pcdata if first value of table
+	if ($element_childs[0] =~ /pcdata/) {
+		shift @element_childs;
+	}
+	foreach $child (@element_childs) {
+		$i = 0;
+		foreach $nochild (@element_nochilds) {
+			if ( $child eq $nochild ) {
+				$i = $i + 1;
+			}
+		}
+		if ( $i == 0 ) {
+			push @children, $child;
+		}
+	}
+	@element_childs = @children;
+	undef @children;
+	$childs = join "', '", @element_childs;
+	$childs = "'" . $childs . "'";
+	$childs =~ s/'EMPTY'//;
+
+	if ( $childs =~ '^$') {
+		$taginfo .= "\\ '$element': ['/>', ''],\n";
+	}
+
+	print DATA "\\ '".$element."': [\n\\ [$childs],\n";
+
+	%element_attributes = $dtd->get_elem_attr($element);
+	@attr_names = keys %element_attributes;
+	# @attr_values = values %element_attributes;
+	print DATA '\ { ';
+	$attrs = '';
+	foreach $attr_name (@attr_names) {
+		foreach $item (@{$element_attributes{$attr_name}}) {
+			if ($item !~ /(IMPLIED|FIXED|REQUIRED|CDATA|ID|ENTIT|NAME|NUMBER|NMTOKEN|NOTATION)/) {
+				# IDREF, IDREFS, NMTOKENS, ENTITIES will be cared of by super-strings
+				push @val, $item;
+			}
+			#if ($item =~ /REQUIRED/) {
+				#push @req, $attr_name;
+				#$req{$attr_name} = '1';
+				#}
+		}
+		if (@val) {
+			$attr_vls = join "', '", @val;
+			$attr_vls = "'" . $attr_vls . "'";
+			undef @val;
+		}
+		$attrs .= "'".$attr_name ."': [$attr_vls], ";
+		undef $attr_vls;
+	}
+	$attrs =~ s/..$//;
+	print DATA $attrs;
+	print DATA "}\n\\ ],\n";
+}
+
+#$req = join "': ['*', ''],\n\\ '", keys %req;
+#$req = "\\ '" . $req . "': ['*', '']";
+#print DATA "\\ 'vimxmlattrinfo': {\n$req\n\\ },\n";
+print DATA "\\ 'vimxmltaginfo': {\n$taginfo\\ }";
+
+# Close big dictionary and add modeline to data file
+print DATA "\n\\ }\n\" vim:ft=vim:ff=unix";
+
+# Space necessary to get above line from default 'modelines' range
+#
+#
+#
+
+close DATA or die "$!";
+
+# vim:isk+=$,%:ft=perl:ff=unix:tw=80:fo+=o:

Propchange: trunk/packages/vim-scripts/bin/dtd2vim
------------------------------------------------------------------------------
    svn:executable = *

Modified: trunk/packages/vim-scripts/debian/TODO.Debian
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/TODO.Debian?rev=856&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/TODO.Debian (original)
+++ trunk/packages/vim-scripts/debian/TODO.Debian Sat Jan 20 13:24:58 2007
@@ -1,3 +1,7 @@
+- write the manpage for dtd2vim
+
+ -- Stefano Zacchiroli <zack at debian.org>  Sat, 20 Jan 2007 13:24:19 +0100
+
 - write a script debian/find-missing which compares files listed in
   debian/vim-scripts.status with all the files shipped in the vim-scripts
   package to ensure that no file is not listed in the status file (and hence

Modified: trunk/packages/vim-scripts/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/changelog?rev=856&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/changelog (original)
+++ trunk/packages/vim-scripts/debian/changelog Sat Jan 20 13:24:58 2007
@@ -3,8 +3,11 @@
   * debian/control
     - use abbreviated form ("XS-Vcs-Svn") for the svn field
     - set maintainer to Debian VIM Maintainers and Uploaders to me and Michael
+  * addons adds/removals/upgrades
+    - added binary dtd2vim to generate XML data file for Vim 7 DTD-based omni
+      completion
 
- -- Stefano Zacchiroli <zack at debian.org>  Fri, 19 Jan 2007 11:14:11 +0100
+ -- Stefano Zacchiroli <zack at debian.org>  Sat, 20 Jan 2007 13:21:28 +0100
 
 vim-scripts (7.0.4) unstable; urgency=low
 

Modified: trunk/packages/vim-scripts/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/copyright?rev=856&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/copyright (original)
+++ trunk/packages/vim-scripts/debian/copyright Sat Jan 20 13:24:58 2007
@@ -12,115 +12,120 @@
 posted on vim.org their licence is at least as free as the licence of Vim
 itself.
 
-script:  plugin/a.vim;
+script:  plugin/a.vim
 author:  Mike Sharpe < feline at irendi.com >
 url:	 http://www.vim.org/scripts/script.php?script_id=31
 license: license [1], see below
 
-script:  plugin/whatdomain.vim;
+script:  plugin/whatdomain.vim
 author:  Michael Piefel < piefel at informatik.hu-berlin.de >
 url:	 http://www.vim.org/scripts/script.php?script_id=62
 license: public domain
 
-script:  plugin/bufexplorer.vim;
+script:  plugin/bufexplorer.vim
 author:  Jeff Lanzarotta < delux256-vim at yahoo dot com >
 url:	 http://www.vim.org/scripts/script.php?script_id=42
 license: license [2], see below
 
-script:  plugin/minibufexpl.vim;
+script:  plugin/minibufexpl.vim
 author:  Bindu Wavell < bindu at wavell.net >
 url:	 http://www.vim.org/scripts/script.php?script_id=159
 license: license [2], see below
 
-script:  plugin/gnupg.vim;
+script:  plugin/gnupg.vim
 author:  Markus Braun < markus.braun at krawel.de >
 url:	 http://www.vim.org/scripts/script.php?script_id=661
 license: no license
 
-script:  plugin/taglist.vim;
+script:  plugin/taglist.vim
 author:  Yegappan Lakshmanan < yegappan at yahoo.com >
 url:	 http://www.vim.org/scripts/script.php?script_id=273
 license: no license
 
-script:  plugin/calendar.vim;
+script:  plugin/calendar.vim
 author:  Yasuhiro Matsumoto < mattn_jp at mail.goo.ne.jp >
 url:	 http://www.vim.org/scripts/script.php?script_id=52
 license: no license
 
-script:  plugin/winmanager.vim;
+script:  plugin/winmanager.vim
 author:  Srinath Avadhanula < srinath at fastmail.fm >
 url:	 http://www.vim.org/scripts/script.php?script_id=95
 license: no license
 
-script:  plugin/AlignPlugin.vim;
+script:  plugin/AlignPlugin.vim
 author:  Charles Campbell < drchip at campbellfamily.biz >
 url:	 http://www.vim.org/scripts/script.php?script_id=294
 license: GNU GPL, see /usr/share/common-licenses/GPL-2
 
-script:  plugin/cvsmenu.vim;
+script:  plugin/cvsmenu.vim
 author:  Yongwei Wu, Thorsten Maerz < adah at sh163.net >
 url:	 http://www.vim.org/scripts/script.php?script_id=1245
 license: GNU LGPL, see /usr/share/common-licenses/LGPL-2
 
-script:  plugin/vcscommand.vim;
+script:  plugin/vcscommand.vim
 author:  Robert Hiestand < bob.hiestand at gmail.com >
 url:	 http://www.vim.org/scripts/script.php?script_id=90
 license: public domain
 
-script:  plugin/utl.vim;
+script:  plugin/utl.vim
 author:  Stefan Bittner < stb at bf-consulting.de >
 url:	 http://www.vim.org/scripts/script.php?script_id=293
 license: GNU GPL, see /usr/share/common-licenses/GPL-2
 
-script:  plugin/info.vim;
+script:  plugin/info.vim
 author:  Slavik Gorbanyov < rnd at web-drive.ru >
 url:	 http://www.vim.org/scripts/script.php?script_id=21
 license: license [3], see below
 
-script:  plugin/EnhancedCommentify.vim;
+script:  plugin/EnhancedCommentify.vim
 author:  Meikel Brandmeyer < Brandels_Mikesh at web.de >
 url:	 http://www.vim.org/scripts/script.php?script_id=23
 license: BSD, see /usr/share/common-licenses/BSD
 
-script:  ftplugin/xml.vim;
+script:  ftplugin/xml.vim
 author:  Devin Weaver < devin at tritarget.com >
 url:	 http://www.vim.org/scripts/script.php?script_id=301
 license: no license
 
-script:  ftplugin/po.vim;
+script:  ftplugin/po.vim
 author:  Aleksandar Jelenak < ajelenak at yahoo.com >
 url:	 http://www.vim.org/scripts/script.php?script_id=695
 license: no license
 
-script:  games/tetris.vim;
+script:  games/tetris.vim
 author:  Gergely Kontra < kgergely at mcl.hu >
 url:	 http://www.vim.org/scripts/script.php?script_id=172
 license: no license
 
-script:  games/VimSokoban/sokoban.vim;
+script:  games/VimSokoban/sokoban.vim
 author:  Mike Sharpe < feline at irendi.com >
 url:	 http://www.vim.org/scripts/script.php?script_id=211
 license: license [1], see below
 
-script:  plugin/themes.vim;
+script:  plugin/themes.vim
 author:  Robert (MetaCosm) < vim at metacosm.dhs.org >
 url:	 http://www.vim.org/scripts/script.php?script_id=625
 license: see colors/*.vim for per color scheme licenses
 
-script:  macros/closetag.vim;
+script:  macros/closetag.vim
 author:  Steven Mueller < diffusor at ugcs.caltech.edu >
 url:	 http://vim.sourceforge.net/scripts/script.php?script_id=13
 license: no license
 
-script:  plugin/NERD_comments.vim;
+script:  plugin/NERD_comments.vim
 author:  Marty Grenfell < mrg39 at student.canterbury.ac.nz >
 url:	 http://www.vim.org/scripts/script.php?script_id=1218
 license: no license
 
-script:  plugin/project.vim;
+script:  plugin/project.vim
 author:  Aric Blumer < aricvim at charter.net >
 url:	 http://www.vim.org/scripts/script.php?script_id=69
 license: no license
+
+script:  dtd2vim
+author:  Mikolaj Machowski < mikmach at wp.pl >
+url:	 http://www.vim.org/scripts/script.php?script_id=1462
+license: GNU GPL, see /usr/share/common-licenses/GPL-2
 
 --
 

Modified: trunk/packages/vim-scripts/debian/dirs
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/dirs?rev=856&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/dirs (original)
+++ trunk/packages/vim-scripts/debian/dirs Sat Jan 20 13:24:58 2007
@@ -1,2 +1,3 @@
+usr/bin/
+usr/share/vim/registry/
 usr/share/vim-scripts/
-usr/share/vim/registry/

Modified: trunk/packages/vim-scripts/debian/install
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/install?rev=856&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/install (original)
+++ trunk/packages/vim-scripts/debian/install Sat Jan 20 13:24:58 2007
@@ -6,4 +6,5 @@
 macros/     			usr/share/vim-scripts/
 plugin/	    			usr/share/vim-scripts/
 syntax/	    			usr/share/vim-scripts/
+bin/*				usr/bin/
 debian/vim-registry/*.yaml	usr/share/vim/registry/

Modified: trunk/packages/vim-scripts/debian/vim-scripts.pl
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/vim-scripts.pl?rev=856&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/vim-scripts.pl (original)
+++ trunk/packages/vim-scripts/debian/vim-scripts.pl Sat Jan 20 13:24:58 2007
@@ -86,6 +86,7 @@
 
 sub emit_registry($$$$) {
   my ($addon, $description, $script_name, $extras) = @_;
+  return if $addon eq '';
   print "addon: $addon\n";
   print "description: \"$description\"\n";
   print "basedir: /usr/share/vim-scripts/\n";
@@ -106,7 +107,7 @@
 my ($script_name, $script_url, $author, $author_url, $email, $license, $extras,
   $description, $version, $addon);
 my $skip = 1;
-$script_name = ''; $extras = '';
+$script_name = ''; $extras = ''; #addon = '';
 while (my $line = <STATUS>) {
   # assumption: each plugin "block" of lines starts with the "script_name:"
   # field
@@ -123,6 +124,7 @@
       emit_registry($addon, $description, $script_name, $extras)
 	if $action eq "registry";
       $extras = '';
+      $addon = '';
     }
     $script_name = $1;
   } elsif ($line =~ /^addon:\s*(.*)/) { $addon = $1; }
@@ -157,7 +159,7 @@
         }
       } elsif ($action eq "copyright") {
 	print <<EOP;
-script:  $script_name;
+script:  $script_name
 author:  $author < $email >
 url:	 $script_url
 license: $license

Modified: trunk/packages/vim-scripts/debian/vim-scripts.status
URL: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim-scripts/debian/vim-scripts.status?rev=856&op=diff
==============================================================================
--- trunk/packages/vim-scripts/debian/vim-scripts.status (original)
+++ trunk/packages/vim-scripts/debian/vim-scripts.status Sat Jan 20 13:24:58 2007
@@ -244,6 +244,15 @@
 extras:      doc/project.txt
 version:     1.4.1
 
+script_name: dtd2vim
+description: create XML data file for Vim7 XML omni-completion from DTDs
+script_url:  http://www.vim.org/scripts/script.php?script_id=1462
+author:      Mikolaj Machowski
+author_url:  http://www.vim.org/account/profile.php?user_id=488
+email:       mikmach at wp.pl
+license:     GNU GPL, see /usr/share/common-licenses/GPL-2
+version:     2.0
+
 --
 
 Licenses referenced above




More information about the pkg-vim-maintainers mailing list