diff --git a/.shipit b/.shipit new file mode 100644 index 0000000..b88aeee --- /dev/null +++ b/.shipit @@ -0,0 +1,8 @@ +# auto-generated shipit config file. +steps = CommitMessageWrap, FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN + +svn.tagpattern = release-%v +commit_message.format = lang/perl/Pod-ProjectDocs: %msg + +# svn.tagpattern = http://code.example.com/svn/tags/MyProj-%v +# CheckChangeLog.files = ChangeLog, MyProj.CHANGES diff --git a/Changes b/Changes new file mode 100644 index 0000000..7bde7ef --- /dev/null +++ b/Changes @@ -0,0 +1,115 @@ +Revision history for Perl extension Pod::ProjectDocs. + +0.38 Thr Mar 11 01:20:00 2010 + - fixed pod2projdocs typo + Thanks to Tokuhiro Matsuno and Naoki Tomita + +0.36 Wed May 14 10:20:00 2008 + - $json->objToJson => $json->encode + objToJson prints deprecated warnings. + Thanks to tokuhirom. + +0.35 Fri Jan 18 18:10:00 2008 + - removed $json->autoconv(0) because JSON doesn't have autoconv method from version 2. + RT#32408, 32409 + +0.34 Sat Oct 27 21:56:00 2007 + - Fixed pod2projdocs bug. + Added METHOD_REGEXP, now you can control pattern that the parser consider as method. + Thanks to Ktat. + +0.33 Mon Oct 15 01:55:00 2007 + - Fixed document of pod2projdocs - added description for forcegen option. + Now it shows it's usage when excused without any option. + Applyed a patch that makes JSON's autoconvert functionality off. + Thanks to Ktat. + +0.31 Mon Jan 29 12:00:00 2007 + - Changed to use Module::Install for instllation, + and made dependency on Syntax::Highlight::Universal optional. + +0.30 Tue Jan 09 12:00:00 2007 + - applyed a great patch from Ankur Gupta. + Now you can see syntax highlighten source code below the document for each methods. + When the parser finds format like "=head2 method_name", it appends source code block + on HTML. Click the anchor "[Source]", and it toggles the source code block. + +0.26 Tue Jul 11 02:00:00 2006 + - added 'except' parameter, + Thanks to Nadim. + +0.22 Tue Dec 11 02:00:00 2005 + - now generated files are strict xhtml. + +0.21 Tue Sep 27 13:00:00 2005 + - added function highlighting matched word + +0.20 Tue Sep 27 12:00:00 2005 + - fixed test script + +0.19 Tue Sep 27 02:00:00 2005 + - fixed some bug + - added search box to index page + reported by Nadim + +0.18 Tue Sep 13 22:33:00 2005 + - fixed _htmlEscape in parser to prevent to put out not intended results + with double html-escaping + reported by Tatsuhiko Miyagawa + +0.17 Sun Sep 4 00:07:00 2005 + - fixed MANIFEST + +0.16 Sun Sep 4 00:07:00 2005 + - fixed Makefile.PL + +0.15 Sat Sep 3 22:04:00 2005 + - added option 'forcegen' + - fixed parser, now it creates link for L properly. + patched by Tatsuhiko Miyagawa. + +0.14 Sat Sep 3 11:56:00 2005 + - fixed mismapping in Pod::ProjectDocs::Parser + found by Tatsuhiko Miyagawa. + +0.13 Sat Aug 27 14:00:00 2005 + - fixed Makefile.PL, to remove bug appears in old version of Pod::Parser. + Reported by Tatsuhiko Miyagawa. + +0.12 Fri Aug 26 23:00:00 2005 + - add footer + +0.11 Fri Aug 26 22:00:00 2005 + - fixed bug in DocManager + +0.1 Fri Aug 26 02:00:00 2005 + - fixed bug that doesn't create 'src' directory. + - fixed parser html-building-process little bit. + - fixed bug by typo in DocManager + - add manager for trigger-scripts ('.cgi', '.pl' files) + +0.09 Sat Aug 20 02:00:00 2005 + - fixed problem about namespace confliction between '.pm' and '.js'. + +0.08 Fri Aug 19 12:00:00 2005 + - fixed not to use Pod::Xhtml. + - add manager for javascript libraries. + +0.07 Thu Aug 18 23:00:00 2005 + - add link to source file. + - fixed to check last modified time. + +0.06 Thu Aug 18 18:00:00 2005 + - fixed to handle multiple 'libroot' by patch from Tatsuhiko Miyagawa. + +0.05 Fri Jun 24 18:00:00 2005 + - fixed bug. + now you can set relative path for -lib and -out options. + +0.02 Sat Jun 18 18:00:00 2005 + - CPAN release version; + +0.01 Thu Jun 16 16:52:20 2005 + - original version; created by h2xs 1.23 with options + -X -A Pod::ProjectDocs + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..266c95f --- /dev/null +++ b/MANIFEST @@ -0,0 +1,36 @@ +bin/pod2projdocs +Changes +inc/Module/AutoInstall.pm +inc/Module/Install.pm +inc/Module/Install/AutoInstall.pm +inc/Module/Install/Base.pm +inc/Module/Install/Can.pm +inc/Module/Install/Fetch.pm +inc/Module/Install/Include.pm +inc/Module/Install/Makefile.pm +inc/Module/Install/Metadata.pm +inc/Module/Install/Scripts.pm +inc/Module/Install/Win32.pm +inc/Module/Install/WriteAll.pm +lib/Pod/ProjectDocs.pm +lib/Pod/ProjectDocs/ArrowImage.pm +lib/Pod/ProjectDocs/Config.pm +lib/Pod/ProjectDocs/CSS.pm +lib/Pod/ProjectDocs/Doc.pm +lib/Pod/ProjectDocs/DocManager.pm +lib/Pod/ProjectDocs/File.pm +lib/Pod/ProjectDocs/IndexPage.pm +lib/Pod/ProjectDocs/Parser.pm +lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm +lib/Pod/ProjectDocs/Parser/PerlPod.pm +lib/Pod/ProjectDocs/Template.pm +Makefile.PL +MANIFEST +META.yml Module meta-data (added by MakeMaker) +README +t/00_compile.t +t/01_project.t +t/02_module.t +t/sample/lib/Sample/Module.pm +t/sample/lib/Sample/Project.pm +t/sample/lib2/Module.pm diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..5866ad7 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,13 @@ +\bRCS\b +\bCVS\b +^MANIFEST\. +^Makefile$ +~$ +\.old$ +^blib/ +^pm_to_blib +^MakeMaker-\d +\.gz$ +\.cvsignore +^9\d_.*\.t +\.svn diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..fd0063d --- /dev/null +++ b/META.yml @@ -0,0 +1,24 @@ +# http://module-build.sourceforge.net/META-spec.html +#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# +name: Pod-ProjectDocs +version: 0.30 +version_from: lib/Pod/ProjectDocs.pm +installdirs: site +requires: + Class::Accessor::Fast: 0 + Class::Data::Inheritable: 0 + File::Basename: 0 + File::Copy: 0 + File::Find: 0 + File::Spec: 0 + JSON: 0.991 + MIME::Base64: 0 + Pod::Parser: 1.32 + Pod::ParseUtils: 0 + Readonly: 0 + Syntax::Highlight::Universal: 0 + Template: 0 + URI::Escape: 0 + +distribution_type: module +generated_by: ExtUtils::MakeMaker version 6.30 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..97eebd2 --- /dev/null +++ b/Makefile @@ -0,0 +1,901 @@ +# This Makefile is for the Pod::ProjectDocs extension to perl. +# +# It was generated automatically by MakeMaker version +# 6.48 (Revision: 64800) from the contents of +# Makefile.PL. Don't edit this file, edit Makefile.PL instead. +# +# ANY CHANGES MADE HERE WILL BE LOST! +# +# MakeMaker ARGV: () +# +# MakeMaker Parameters: + +# ABSTRACT => q[generates CPAN like pod pages] +# AUTHOR => q[Lyo Kato ] +# DIR => [] +# DISTNAME => q[Pod-ProjectDocs] +# EXE_FILES => [q[bin/pod2projdocs]] +# NAME => q[Pod::ProjectDocs] +# NO_META => q[1] +# PL_FILES => { } +# PREREQ_PM => { File::Copy=>q[0], URI::Escape=>q[0], ExtUtils::MakeMaker=>q[6.42], File::Spec=>q[0], Pod::Parser=>q[1.32], Template=>q[0], Class::Accessor::Fast=>q[0], Readonly=>q[0], Pod::ParseUtils=>q[0], MIME::Base64=>q[0], File::Find=>q[0], Class::Data::Inheritable=>q[0], File::Basename=>q[0], JSON=>q[2.04] } +# VERSION => q[0.38] +# dist => { PREOP=>q[$(PERL) -I. "-MModule::Install::Admin" -e "dist_preop(q($(DISTVNAME)))"] } +# realclean => { FILES=>q[MYMETA.yml] } +# test => { TESTS=>q[t/00_compile.t t/01_project.t t/02_module.t] } + +# --- MakeMaker post_initialize section: + + +# --- MakeMaker const_config section: + +# These definitions are from config.sh (via /opt/local/lib/perl5/5.8.9/darwin-2level/Config.pm). +# They may have been overridden via Makefile.PL or on the command line. +AR = ar +CC = /usr/bin/gcc-4.2 +CCCDLFLAGS = +CCDLFLAGS = +DLEXT = bundle +DLSRC = dl_dlopen.xs +EXE_EXT = +FULL_AR = /usr/bin/ar +LD = env MACOSX_DEPLOYMENT_TARGET=10.3 /usr/bin/gcc-4.2 +LDDLFLAGS = -L/opt/local/lib -bundle -undefined dynamic_lookup +LDFLAGS = -L/opt/local/lib +LIBC = /usr/lib/libc.dylib +LIB_EXT = .a +OBJ_EXT = .o +OSNAME = darwin +OSVERS = 10.0.0 +RANLIB = ranlib +SITELIBEXP = /opt/local/lib/perl5/site_perl/5.8.9 +SITEARCHEXP = /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level +SO = dylib +VENDORARCHEXP = /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level +VENDORLIBEXP = /opt/local/lib/perl5/vendor_perl/5.8.9 + + +# --- MakeMaker constants section: +AR_STATIC_ARGS = cr +DIRFILESEP = / +DFSEP = $(DIRFILESEP) +NAME = Pod::ProjectDocs +NAME_SYM = Pod_ProjectDocs +VERSION = 0.38 +VERSION_MACRO = VERSION +VERSION_SYM = 0_38 +DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" +XS_VERSION = 0.38 +XS_VERSION_MACRO = XS_VERSION +XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" +INST_ARCHLIB = blib/arch +INST_SCRIPT = blib/script +INST_BIN = blib/bin +INST_LIB = blib/lib +INST_MAN1DIR = blib/man1 +INST_MAN3DIR = blib/man3 +MAN1EXT = 1pm +MAN3EXT = 3pm +INSTALLDIRS = site +DESTDIR = +PREFIX = $(SITEPREFIX) +PERLPREFIX = /opt/local +SITEPREFIX = /opt/local +VENDORPREFIX = /opt/local +INSTALLPRIVLIB = /opt/local/lib/perl5/5.8.9 +DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) +INSTALLSITELIB = /opt/local/lib/perl5/site_perl/5.8.9 +DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) +INSTALLVENDORLIB = /opt/local/lib/perl5/vendor_perl/5.8.9 +DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) +INSTALLARCHLIB = /opt/local/lib/perl5/5.8.9/darwin-2level +DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) +INSTALLSITEARCH = /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level +DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) +INSTALLVENDORARCH = /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level +DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) +INSTALLBIN = /opt/local/bin +DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) +INSTALLSITEBIN = /opt/local/bin +DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) +INSTALLVENDORBIN = /opt/local/bin +DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) +INSTALLSCRIPT = /opt/local/bin +DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) +INSTALLSITESCRIPT = /opt/local/bin +DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT) +INSTALLVENDORSCRIPT = /opt/local/bin +DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT) +INSTALLMAN1DIR = /opt/local/share/man/man1p +DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) +INSTALLSITEMAN1DIR = /opt/local/share/man/man1 +DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) +INSTALLVENDORMAN1DIR = /opt/local/share/man/man1 +DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) +INSTALLMAN3DIR = /opt/local/share/man/man3p +DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) +INSTALLSITEMAN3DIR = /opt/local/share/man/man3 +DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) +INSTALLVENDORMAN3DIR = /opt/local/share/man/man3 +DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) +PERL_LIB = +PERL_ARCHLIB = /opt/local/lib/perl5/5.8.9/darwin-2level +LIBPERL_A = libperl.a +FIRST_MAKEFILE = Makefile +MAKEFILE_OLD = Makefile.old +MAKE_APERL_FILE = Makefile.aperl +PERLMAINCC = $(CC) +PERL_INC = /opt/local/lib/perl5/5.8.9/darwin-2level/CORE +PERL = /opt/local/bin/perl "-Iinc" +FULLPERL = /opt/local/bin/perl "-Iinc" +ABSPERL = $(PERL) +PERLRUN = $(PERL) +FULLPERLRUN = $(FULLPERL) +ABSPERLRUN = $(ABSPERL) +PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" +PERL_CORE = 0 +PERM_RW = 644 +PERM_RWX = 755 + +MAKEMAKER = /opt/local/lib/perl5/5.8.9/ExtUtils/MakeMaker.pm +MM_VERSION = 6.48 +MM_REVISION = 64800 + +# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). +# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) +# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) +# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +MAKE = make +FULLEXT = Pod/ProjectDocs +BASEEXT = ProjectDocs +PARENT_NAME = Pod +DLBASE = $(BASEEXT) +VERSION_FROM = +OBJECT = +LDFROM = $(OBJECT) +LINKTYPE = dynamic +BOOTDEP = + +# Handy lists of source code files: +XS_FILES = +C_FILES = +O_FILES = +H_FILES = +MAN1PODS = bin/pod2projdocs +MAN3PODS = lib/Pod/ProjectDocs.pm + +# Where is the Config information that we are using/depend on +CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h + +# Where to build things +INST_LIBDIR = $(INST_LIB)/Pod +INST_ARCHLIBDIR = $(INST_ARCHLIB)/Pod + +INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) +INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) + +INST_STATIC = +INST_DYNAMIC = +INST_BOOT = + +# Extra linker info +EXPORT_LIST = +PERL_ARCHIVE = +PERL_ARCHIVE_AFTER = + + +TO_INST_PM = lib/Pod/ProjectDocs.pm \ + lib/Pod/ProjectDocs/ArrowImage.pm \ + lib/Pod/ProjectDocs/CSS.pm \ + lib/Pod/ProjectDocs/Config.pm \ + lib/Pod/ProjectDocs/Doc.pm \ + lib/Pod/ProjectDocs/DocManager.pm \ + lib/Pod/ProjectDocs/File.pm \ + lib/Pod/ProjectDocs/IndexPage.pm \ + lib/Pod/ProjectDocs/Parser.pm \ + lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm \ + lib/Pod/ProjectDocs/Parser/PerlPod.pm \ + lib/Pod/ProjectDocs/Template.pm + +PM_TO_BLIB = lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm \ + blib/lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm \ + lib/Pod/ProjectDocs/DocManager.pm \ + blib/lib/Pod/ProjectDocs/DocManager.pm \ + lib/Pod/ProjectDocs/Parser.pm \ + blib/lib/Pod/ProjectDocs/Parser.pm \ + lib/Pod/ProjectDocs/IndexPage.pm \ + blib/lib/Pod/ProjectDocs/IndexPage.pm \ + lib/Pod/ProjectDocs.pm \ + blib/lib/Pod/ProjectDocs.pm \ + lib/Pod/ProjectDocs/Template.pm \ + blib/lib/Pod/ProjectDocs/Template.pm \ + lib/Pod/ProjectDocs/ArrowImage.pm \ + blib/lib/Pod/ProjectDocs/ArrowImage.pm \ + lib/Pod/ProjectDocs/CSS.pm \ + blib/lib/Pod/ProjectDocs/CSS.pm \ + lib/Pod/ProjectDocs/Config.pm \ + blib/lib/Pod/ProjectDocs/Config.pm \ + lib/Pod/ProjectDocs/Doc.pm \ + blib/lib/Pod/ProjectDocs/Doc.pm \ + lib/Pod/ProjectDocs/File.pm \ + blib/lib/Pod/ProjectDocs/File.pm \ + lib/Pod/ProjectDocs/Parser/PerlPod.pm \ + blib/lib/Pod/ProjectDocs/Parser/PerlPod.pm + + +# --- MakeMaker platform_constants section: +MM_Unix_VERSION = 6.48 +PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc + + +# --- MakeMaker tool_autosplit section: +# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto +AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' -- + + + +# --- MakeMaker tool_xsubpp section: + + +# --- MakeMaker tools_other section: +SHELL = /bin/sh +CHMOD = chmod +CP = cp +MV = mv +NOOP = $(SHELL) -c true +NOECHO = @ +RM_F = rm -f +RM_RF = rm -rf +TEST_F = test -f +TOUCH = touch +UMASK_NULL = umask 0 +DEV_NULL = > /dev/null 2>&1 +MKPATH = $(ABSPERLRUN) "-MExtUtils::Command" -e mkpath +EQUALIZE_TIMESTAMP = $(ABSPERLRUN) "-MExtUtils::Command" -e eqtime +ECHO = echo +ECHO_N = echo -n +UNINST = 0 +VERBINST = 0 +MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' -- +DOC_INSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install +UNINSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall +WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist +MACROSTART = +MACROEND = +USEMAKEFILE = -f +FIXIN = $(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)" + + +# --- MakeMaker makemakerdflt section: +makemakerdflt : all + $(NOECHO) $(NOOP) + + +# --- MakeMaker dist section: +TAR = COPY_EXTENDED_ATTRIBUTES_DISABLE=1 COPYFILE_DISABLE=1 tar +TARFLAGS = cvf +ZIP = zip +ZIPFLAGS = -r +COMPRESS = gzip --best +SUFFIX = .gz +SHAR = shar +PREOP = $(PERL) -I. "-MModule::Install::Admin" -e "dist_preop(q($(DISTVNAME)))" +POSTOP = $(NOECHO) $(NOOP) +TO_UNIX = $(NOECHO) $(NOOP) +CI = ci -u +RCS_LABEL = rcs -Nv$(VERSION_SYM): -q +DIST_CP = best +DIST_DEFAULT = tardist +DISTNAME = Pod-ProjectDocs +DISTVNAME = Pod-ProjectDocs-0.38 + + +# --- MakeMaker macro section: + + +# --- MakeMaker depend section: + + +# --- MakeMaker cflags section: + + +# --- MakeMaker const_loadlibs section: + + +# --- MakeMaker const_cccmd section: + + +# --- MakeMaker post_constants section: + + +# --- MakeMaker pasthru section: + +PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ + LINKTYPE="$(LINKTYPE)"\ + PREFIX="$(PREFIX)" + + +# --- MakeMaker special_targets section: +.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) + +.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir + + + +# --- MakeMaker c_o section: + + +# --- MakeMaker xs_c section: + + +# --- MakeMaker xs_o section: + + +# --- MakeMaker top_targets section: +all :: pure_all manifypods + $(NOECHO) $(NOOP) + + +pure_all :: config pm_to_blib subdirs linkext + $(NOECHO) $(NOOP) + +subdirs :: $(MYEXTLIB) + $(NOECHO) $(NOOP) + +config :: $(FIRST_MAKEFILE) blibdirs + $(NOECHO) $(NOOP) + +help : + perldoc ExtUtils::MakeMaker + + +# --- MakeMaker blibdirs section: +blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists + $(NOECHO) $(NOOP) + +# Backwards compat with 6.18 through 6.25 +blibdirs.ts : blibdirs + $(NOECHO) $(NOOP) + +$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_LIBDIR) + $(NOECHO) $(CHMOD) 755 $(INST_LIBDIR) + $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists + +$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHLIB) + $(NOECHO) $(CHMOD) 755 $(INST_ARCHLIB) + $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists + +$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_AUTODIR) + $(NOECHO) $(CHMOD) 755 $(INST_AUTODIR) + $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists + +$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) + $(NOECHO) $(CHMOD) 755 $(INST_ARCHAUTODIR) + $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists + +$(INST_BIN)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_BIN) + $(NOECHO) $(CHMOD) 755 $(INST_BIN) + $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists + +$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_SCRIPT) + $(NOECHO) $(CHMOD) 755 $(INST_SCRIPT) + $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists + +$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN1DIR) + $(NOECHO) $(CHMOD) 755 $(INST_MAN1DIR) + $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists + +$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN3DIR) + $(NOECHO) $(CHMOD) 755 $(INST_MAN3DIR) + $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists + + + +# --- MakeMaker linkext section: + +linkext :: $(LINKTYPE) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dlsyms section: + + +# --- MakeMaker dynamic section: + +dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) + $(NOECHO) $(NOOP) + + +# --- MakeMaker dynamic_bs section: + +BOOTSTRAP = + + +# --- MakeMaker dynamic_lib section: + + +# --- MakeMaker static section: + +## $(INST_PM) has been moved to the all: target. +## It remains here for awhile to allow for old usage: "make static" +static :: $(FIRST_MAKEFILE) $(INST_STATIC) + $(NOECHO) $(NOOP) + + +# --- MakeMaker static_lib section: + + +# --- MakeMaker manifypods section: + +POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" +POD2MAN = $(POD2MAN_EXE) + + +manifypods : pure_all \ + bin/pod2projdocs \ + lib/Pod/ProjectDocs.pm + $(NOECHO) $(POD2MAN) --section=1 --perm_rw=$(PERM_RW) \ + bin/pod2projdocs $(INST_MAN1DIR)/pod2projdocs.$(MAN1EXT) + $(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) \ + lib/Pod/ProjectDocs.pm $(INST_MAN3DIR)/Pod::ProjectDocs.$(MAN3EXT) + + + + +# --- MakeMaker processPL section: + + +# --- MakeMaker installbin section: + +EXE_FILES = bin/pod2projdocs + +pure_all :: $(INST_SCRIPT)/pod2projdocs + $(NOECHO) $(NOOP) + +realclean :: + $(RM_F) \ + $(INST_SCRIPT)/pod2projdocs + +$(INST_SCRIPT)/pod2projdocs : bin/pod2projdocs $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists + $(NOECHO) $(RM_F) $(INST_SCRIPT)/pod2projdocs + $(CP) bin/pod2projdocs $(INST_SCRIPT)/pod2projdocs + $(FIXIN) $(INST_SCRIPT)/pod2projdocs + -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_SCRIPT)/pod2projdocs + + + +# --- MakeMaker subdirs section: + +# none + +# --- MakeMaker clean_subdirs section: +clean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker clean section: + +# Delete temporary files but do not touch installed files. We don't delete +# the Makefile here so a later make realclean still has a makefile to use. + +clean :: clean_subdirs + - $(RM_F) \ + *$(LIB_EXT) core \ + core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \ + core.[0-9][0-9] $(BASEEXT).bso \ + pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \ + $(BASEEXT).x $(BOOTSTRAP) \ + perl$(EXE_EXT) tmon.out \ + *$(OBJ_EXT) pm_to_blib \ + $(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \ + core.[0-9][0-9][0-9][0-9][0-9] *perl.core \ + core.*perl.*.? $(MAKE_APERL_FILE) \ + perl $(BASEEXT).def \ + core.[0-9][0-9][0-9] mon.out \ + lib$(BASEEXT).def perlmain.c \ + perl.exe so_locations \ + $(BASEEXT).exp + - $(RM_RF) \ + blib + - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) + + +# --- MakeMaker realclean_subdirs section: +realclean_subdirs : + $(NOECHO) $(NOOP) + + +# --- MakeMaker realclean section: +# Delete temporary files (via clean) and also delete dist files +realclean purge :: clean realclean_subdirs + - $(RM_F) \ + $(MAKEFILE_OLD) $(FIRST_MAKEFILE) + - $(RM_RF) \ + MYMETA.yml $(DISTVNAME) + + +# --- MakeMaker metafile section: +metafile : + $(NOECHO) $(NOOP) + + +# --- MakeMaker signature section: +signature : + cpansign -s + + +# --- MakeMaker dist_basics section: +distclean :: realclean distcheck + $(NOECHO) $(NOOP) + +distcheck : + $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck + +skipcheck : + $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck + +manifest : + $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest + +veryclean : realclean + $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old + + + +# --- MakeMaker dist_core section: + +dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) + $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ + -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' -- + +tardist : $(DISTVNAME).tar$(SUFFIX) + $(NOECHO) $(NOOP) + +uutardist : $(DISTVNAME).tar$(SUFFIX) + uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu + +$(DISTVNAME).tar$(SUFFIX) : distdir + $(PREOP) + $(TO_UNIX) + $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(COMPRESS) $(DISTVNAME).tar + $(POSTOP) + +zipdist : $(DISTVNAME).zip + $(NOECHO) $(NOOP) + +$(DISTVNAME).zip : distdir + $(PREOP) + $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) + $(RM_RF) $(DISTVNAME) + $(POSTOP) + +shdist : distdir + $(PREOP) + $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar + $(RM_RF) $(DISTVNAME) + $(POSTOP) + + +# --- MakeMaker distdir section: +create_distdir : + $(RM_RF) $(DISTVNAME) + $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ + -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" + +distdir : create_distdir + $(NOECHO) $(NOOP) + + + +# --- MakeMaker dist_test section: +disttest : distdir + cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL + cd $(DISTVNAME) && $(MAKE) $(PASTHRU) + cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) + + + +# --- MakeMaker dist_ci section: + +ci : + $(PERLRUN) "-MExtUtils::Manifest=maniread" \ + -e "@all = keys %{ maniread() };" \ + -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ + -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" + + +# --- MakeMaker distmeta section: +distmeta : create_distdir metafile + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' -- + + + +# --- MakeMaker distsignature section: +distsignature : create_distdir + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' -- + $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE + cd $(DISTVNAME) && cpansign -s + + + +# --- MakeMaker install section: + +install :: all pure_install doc_install + $(NOECHO) $(NOOP) + +install_perl :: all pure_perl_install doc_perl_install + $(NOECHO) $(NOOP) + +install_site :: all pure_site_install doc_site_install + $(NOECHO) $(NOOP) + +install_vendor :: all pure_vendor_install doc_vendor_install + $(NOECHO) $(NOOP) + +pure_install :: pure_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) + +doc_install :: doc_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) + +pure__install : pure_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +doc__install : doc_site_install + $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site + +pure_perl_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLPRIVLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ + $(INST_BIN) $(DESTINSTALLBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(SITEARCHEXP)/auto/$(FULLEXT) + + +pure_site_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLSITELIB) \ + $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ + $(INST_BIN) $(DESTINSTALLSITEBIN) \ + $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) + $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ + $(PERL_ARCHLIB)/auto/$(FULLEXT) + +pure_vendor_install :: + $(NOECHO) $(MOD_INSTALL) \ + read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ + write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ + $(INST_LIB) $(DESTINSTALLVENDORLIB) \ + $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ + $(INST_BIN) $(DESTINSTALLVENDORBIN) \ + $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \ + $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ + $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) + +doc_perl_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLPRIVLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_site_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLSITELIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + +doc_vendor_install :: + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod + -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) + -$(NOECHO) $(DOC_INSTALL) \ + "Module" "$(NAME)" \ + "installed into" "$(INSTALLVENDORLIB)" \ + LINKTYPE "$(LINKTYPE)" \ + VERSION "$(VERSION)" \ + EXE_FILES "$(EXE_FILES)" \ + >> $(DESTINSTALLARCHLIB)/perllocal.pod + + +uninstall :: uninstall_from_$(INSTALLDIRS)dirs + $(NOECHO) $(NOOP) + +uninstall_from_perldirs :: + $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist + +uninstall_from_sitedirs :: + $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist + +uninstall_from_vendordirs :: + $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist + + +# --- MakeMaker force section: +# Phony target to force checking subdirectories. +FORCE : + $(NOECHO) $(NOOP) + + +# --- MakeMaker perldepend section: + + +# --- MakeMaker makefile section: +# We take a very conservative approach here, but it's worth it. +# We move Makefile to Makefile.old here to avoid gnu make looping. +$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) + $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" + $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." + -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) + -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) + $(PERLRUN) Makefile.PL + $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" + $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" + false + + + +# --- MakeMaker staticmake section: + +# --- MakeMaker makeaperl section --- +MAP_TARGET = perl +FULLPERL = /opt/local/bin/perl + +$(MAP_TARGET) :: static $(MAKE_APERL_FILE) + $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ + +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib + $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) + $(NOECHO) $(PERLRUNINST) \ + Makefile.PL DIR= \ + MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ + MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= + + +# --- MakeMaker test section: + +TEST_VERBOSE=0 +TEST_TYPE=test_$(LINKTYPE) +TEST_FILE = test.pl +TEST_FILES = t/00_compile.t t/01_project.t t/02_module.t +TESTDB_SW = -d + +testdb :: testdb_$(LINKTYPE) + +test :: $(TEST_TYPE) subdirs-test + +subdirs-test :: + $(NOECHO) $(NOOP) + + +test_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) + +testdb_dynamic :: pure_all + PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-Iinc" "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) + +test_ : test_dynamic + +test_static :: test_dynamic +testdb_static :: testdb_dynamic + + +# --- MakeMaker ppd section: +# Creates a PPD (Perl Package Description) for a binary distribution. +ppd : + $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' $(DISTNAME)' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' generates CPAN like pod pages' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' Lyo Kato <lyo.kato@gmail.com>' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd + + +# --- MakeMaker pm_to_blib section: + +pm_to_blib : $(TO_INST_PM) + $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')' -- \ + lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm blib/lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm \ + lib/Pod/ProjectDocs/DocManager.pm blib/lib/Pod/ProjectDocs/DocManager.pm \ + lib/Pod/ProjectDocs/Parser.pm blib/lib/Pod/ProjectDocs/Parser.pm \ + lib/Pod/ProjectDocs/IndexPage.pm blib/lib/Pod/ProjectDocs/IndexPage.pm \ + lib/Pod/ProjectDocs.pm blib/lib/Pod/ProjectDocs.pm \ + lib/Pod/ProjectDocs/Template.pm blib/lib/Pod/ProjectDocs/Template.pm \ + lib/Pod/ProjectDocs/ArrowImage.pm blib/lib/Pod/ProjectDocs/ArrowImage.pm \ + lib/Pod/ProjectDocs/CSS.pm blib/lib/Pod/ProjectDocs/CSS.pm \ + lib/Pod/ProjectDocs/Config.pm blib/lib/Pod/ProjectDocs/Config.pm \ + lib/Pod/ProjectDocs/Doc.pm blib/lib/Pod/ProjectDocs/Doc.pm \ + lib/Pod/ProjectDocs/File.pm blib/lib/Pod/ProjectDocs/File.pm \ + lib/Pod/ProjectDocs/Parser/PerlPod.pm blib/lib/Pod/ProjectDocs/Parser/PerlPod.pm + $(NOECHO) $(TOUCH) pm_to_blib + + +# --- MakeMaker selfdocument section: + + +# --- MakeMaker postamble section: + + +# End. +# Postamble by Module::Install 0.93 +# --- Module::Install::Admin::Makefile section: + +realclean purge :: + $(RM_F) $(DISTVNAME).tar$(SUFFIX) + $(RM_F) MANIFEST.bak _build + $(PERL) "-Ilib" "-MModule::Install::Admin" -e "remove_meta()" + $(RM_RF) inc + +reset :: purge + +upload :: test dist + cpan-upload -verbose $(DISTVNAME).tar$(SUFFIX) + +grok :: + perldoc Module::Install + +distsign :: + cpansign -s + +# --- Module::Install::AutoInstall section: + +config :: installdeps + $(NOECHO) $(NOOP) + +checkdeps :: + $(PERL) Makefile.PL --checkdeps + +installdeps :: + $(NOECHO) $(NOOP) + diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..258f253 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,27 @@ +use inc::Module::Install; + +name 'Pod-ProjectDocs'; +all_from 'lib/Pod/ProjectDocs.pm'; +install_script 'bin/pod2projdocs'; +requires 'Pod::Parser' => 1.32; +requires 'Pod::ParseUtils' => 0; +requires 'Class::Accessor::Fast' => 0; +requires 'Class::Data::Inheritable' => 0; +requires 'File::Spec' => 0; +requires 'File::Basename' => 0; +requires 'File::Find' => 0; +requires 'File::Copy' => 0; +requires 'MIME::Base64' => 0; +requires 'Template' => 0; +requires 'Readonly' => 0; +requires 'URI::Escape' => 0; +requires 'JSON' => 2.04; +features( + 'Syntax Highlighten' => [ + -default => 1, + recommends('Syntax::Highlight::Universal'), + ] +); +auto_install; +WriteAll; + diff --git a/README b/README new file mode 100644 index 0000000..f6be022 --- /dev/null +++ b/README @@ -0,0 +1,21 @@ +Pod-ProjectDocs version 0.34 +============================ + +INSTALLATION + +To install this module type the following: + + perl Makefile.PL + make + make test + make install + +COPYRIGHT AND LICENCE + +Copyright (C) 2005 by Lyo Kato + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.8.5 or, +at your option, any later version of Perl 5 you may have available. + + diff --git a/bin/pod2projdocs b/bin/pod2projdocs new file mode 100755 index 0000000..976c2ec --- /dev/null +++ b/bin/pod2projdocs @@ -0,0 +1,92 @@ +#!/usr/bin/perl -w + +eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}' if 0; + +use strict; +use Getopt::Long; +use Pod::Usage; +use Pod::ProjectDocs; + +my($out, $lib, $title, $lang, $desc, $charset, $index, $verbose, $forcegen, $except); +my $help = @ARGV == 0; + +my %opt = ( + 'help|?' => \$help, + 'out|o=s' => \$out, + 'lib|l=s@' => \$lib, + 'except|e=s@' => \$except, + 'title|t=s' => \$title, + 'desc|d=s' => \$desc, + 'charset|c=s' => \$charset, + 'index!' => \$index, + 'verbose|v' => \$verbose, + 'forcegen!' => \$forcegen, + 'lang=s' => \$lang, +); + +GetOptions(%opt); + +pod2usage(1) if $help; + +my $p = Pod::ProjectDocs->new( + outroot => $out, + libroot => $lib, + except => $except, + title => $title, + desc => $desc, + charset => $charset, + index => $index, + verbose => $verbose, + forcegen => $forcegen, + lang => $lang, +); +$p->gen; + +=head1 NAME + +pod2projdocs - ganerates CPAN like project documents from pod. + +=head1 SYNOPSIS + +pod2projdocs [options] + + Options: + -help display this help and exists + -out directory path that you want to generate documents into + -lib your project's library-root-directory path + -title your project's title + -desc your project's description + -charset this is used in meta tag in html. default 'UTF-8' + -noindex don't create index on each pod pages. + -forcegen generate documents each time ignoring last modified timestamp + -lang set this language as xml:lang. default 'en' + -except set regex, and the file matches this regex won't be checked + + you can set each options with their first alphabet. + for example, you can write -o instead of -out. + + And you can make documents from multiple library-directories. + + pod2projdocs -o /path/to/outputdir -l /path/to/lib1 -l /path/to/lib2 + +=head1 DESCRIPTION + +generates CPAN like project documents from pod. + +=head1 SEE ALSO + +L + +=head1 AUTHOR + +Lyo Kato Elyo.kato@gmail.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright 2005 Lyo Kato. All rights reserved. + +This library is free software. You can redistribute it and/or modify it under +the same terms as perl itself. + +=cut + diff --git a/inc/Module/AutoInstall.pm b/inc/Module/AutoInstall.pm new file mode 100644 index 0000000..32c2cf3 --- /dev/null +++ b/inc/Module/AutoInstall.pm @@ -0,0 +1,818 @@ +#line 1 +package Module::AutoInstall; + +use strict; +use Cwd (); +use ExtUtils::MakeMaker (); + +use vars qw{$VERSION}; +BEGIN { + $VERSION = '1.03'; +} + +# special map on pre-defined feature sets +my %FeatureMap = ( + '' => 'Core Features', # XXX: deprecated + '-core' => 'Core Features', +); + +# various lexical flags +my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS ); +my ( + $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps +); +my ( $PostambleActions, $PostambleUsed ); + +# See if it's a testing or non-interactive session +_accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN ); +_init(); + +sub _accept_default { + $AcceptDefault = shift; +} + +sub missing_modules { + return @Missing; +} + +sub do_install { + __PACKAGE__->install( + [ + $Config + ? ( UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) + : () + ], + @Missing, + ); +} + +# initialize various flags, and/or perform install +sub _init { + foreach my $arg ( + @ARGV, + split( + /[\s\t]+/, + $ENV{PERL_AUTOINSTALL} || $ENV{PERL_EXTUTILS_AUTOINSTALL} || '' + ) + ) + { + if ( $arg =~ /^--config=(.*)$/ ) { + $Config = [ split( ',', $1 ) ]; + } + elsif ( $arg =~ /^--installdeps=(.*)$/ ) { + __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) ); + exit 0; + } + elsif ( $arg =~ /^--default(?:deps)?$/ ) { + $AcceptDefault = 1; + } + elsif ( $arg =~ /^--check(?:deps)?$/ ) { + $CheckOnly = 1; + } + elsif ( $arg =~ /^--skip(?:deps)?$/ ) { + $SkipInstall = 1; + } + elsif ( $arg =~ /^--test(?:only)?$/ ) { + $TestOnly = 1; + } + elsif ( $arg =~ /^--all(?:deps)?$/ ) { + $AllDeps = 1; + } + } +} + +# overrides MakeMaker's prompt() to automatically accept the default choice +sub _prompt { + goto &ExtUtils::MakeMaker::prompt unless $AcceptDefault; + + my ( $prompt, $default ) = @_; + my $y = ( $default =~ /^[Yy]/ ); + + print $prompt, ' [', ( $y ? 'Y' : 'y' ), '/', ( $y ? 'n' : 'N' ), '] '; + print "$default\n"; + return $default; +} + +# the workhorse +sub import { + my $class = shift; + my @args = @_ or return; + my $core_all; + + print "*** $class version " . $class->VERSION . "\n"; + print "*** Checking for Perl dependencies...\n"; + + my $cwd = Cwd::cwd(); + + $Config = []; + + my $maxlen = length( + ( + sort { length($b) <=> length($a) } + grep { /^[^\-]/ } + map { + ref($_) + ? ( ( ref($_) eq 'HASH' ) ? keys(%$_) : @{$_} ) + : '' + } + map { +{@args}->{$_} } + grep { /^[^\-]/ or /^-core$/i } keys %{ +{@args} } + )[0] + ); + + # We want to know if we're under CPAN early to avoid prompting, but + # if we aren't going to try and install anything anyway then skip the + # check entirely since we don't want to have to load (and configure) + # an old CPAN just for a cosmetic message + + $UnderCPAN = _check_lock(1) unless $SkipInstall; + + while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) { + my ( @required, @tests, @skiptests ); + my $default = 1; + my $conflict = 0; + + if ( $feature =~ m/^-(\w+)$/ ) { + my $option = lc($1); + + # check for a newer version of myself + _update_to( $modules, @_ ) and return if $option eq 'version'; + + # sets CPAN configuration options + $Config = $modules if $option eq 'config'; + + # promote every features to core status + $core_all = ( $modules =~ /^all$/i ) and next + if $option eq 'core'; + + next unless $option eq 'core'; + } + + print "[" . ( $FeatureMap{ lc($feature) } || $feature ) . "]\n"; + + $modules = [ %{$modules} ] if UNIVERSAL::isa( $modules, 'HASH' ); + + unshift @$modules, -default => &{ shift(@$modules) } + if ( ref( $modules->[0] ) eq 'CODE' ); # XXX: bugward combatability + + while ( my ( $mod, $arg ) = splice( @$modules, 0, 2 ) ) { + if ( $mod =~ m/^-(\w+)$/ ) { + my $option = lc($1); + + $default = $arg if ( $option eq 'default' ); + $conflict = $arg if ( $option eq 'conflict' ); + @tests = @{$arg} if ( $option eq 'tests' ); + @skiptests = @{$arg} if ( $option eq 'skiptests' ); + + next; + } + + printf( "- %-${maxlen}s ...", $mod ); + + if ( $arg and $arg =~ /^\D/ ) { + unshift @$modules, $arg; + $arg = 0; + } + + # XXX: check for conflicts and uninstalls(!) them. + my $cur = _load($mod); + if (_version_cmp ($cur, $arg) >= 0) + { + print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n"; + push @Existing, $mod => $arg; + $DisabledTests{$_} = 1 for map { glob($_) } @skiptests; + } + else { + if (not defined $cur) # indeed missing + { + print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n"; + } + else + { + # no need to check $arg as _version_cmp ($cur, undef) would satisfy >= above + print "too old. ($cur < $arg)\n"; + } + + push @required, $mod => $arg; + } + } + + next unless @required; + + my $mandatory = ( $feature eq '-core' or $core_all ); + + if ( + !$SkipInstall + and ( + $CheckOnly + or ($mandatory and $UnderCPAN) + or $AllDeps + or _prompt( + qq{==> Auto-install the } + . ( @required / 2 ) + . ( $mandatory ? ' mandatory' : ' optional' ) + . qq{ module(s) from CPAN?}, + $default ? 'y' : 'n', + ) =~ /^[Yy]/ + ) + ) + { + push( @Missing, @required ); + $DisabledTests{$_} = 1 for map { glob($_) } @skiptests; + } + + elsif ( !$SkipInstall + and $default + and $mandatory + and + _prompt( qq{==> The module(s) are mandatory! Really skip?}, 'n', ) + =~ /^[Nn]/ ) + { + push( @Missing, @required ); + $DisabledTests{$_} = 1 for map { glob($_) } @skiptests; + } + + else { + $DisabledTests{$_} = 1 for map { glob($_) } @tests; + } + } + + if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) { + require Config; + print +"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n"; + + # make an educated guess of whether we'll need root permission. + print " (You may need to do that as the 'root' user.)\n" + if eval '$>'; + } + print "*** $class configuration finished.\n"; + + chdir $cwd; + + # import to main:: + no strict 'refs'; + *{'main::WriteMakefile'} = \&Write if caller(0) eq 'main'; +} + +sub _running_under { + my $thing = shift; + print <<"END_MESSAGE"; +*** Since we're running under ${thing}, I'll just let it take care + of the dependency's installation later. +END_MESSAGE + return 1; +} + +# Check to see if we are currently running under CPAN.pm and/or CPANPLUS; +# if we are, then we simply let it taking care of our dependencies +sub _check_lock { + return unless @Missing or @_; + + my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING}; + + if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) { + return _running_under($cpan_env ? 'CPAN' : 'CPANPLUS'); + } + + require CPAN; + + if ($CPAN::VERSION > '1.89') { + if ($cpan_env) { + return _running_under('CPAN'); + } + return; # CPAN.pm new enough, don't need to check further + } + + # last ditch attempt, this -will- configure CPAN, very sorry + + _load_cpan(1); # force initialize even though it's already loaded + + # Find the CPAN lock-file + my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" ); + return unless -f $lock; + + # Check the lock + local *LOCK; + return unless open(LOCK, $lock); + + if ( + ( $^O eq 'MSWin32' ? _under_cpan() : == getppid() ) + and ( $CPAN::Config->{prerequisites_policy} || '' ) ne 'ignore' + ) { + print <<'END_MESSAGE'; + +*** Since we're running under CPAN, I'll just let it take care + of the dependency's installation later. +END_MESSAGE + return 1; + } + + close LOCK; + return; +} + +sub install { + my $class = shift; + + my $i; # used below to strip leading '-' from config keys + my @config = ( map { s/^-// if ++$i; $_ } @{ +shift } ); + + my ( @modules, @installed ); + while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) { + + # grep out those already installed + if ( _version_cmp( _load($pkg), $ver ) >= 0 ) { + push @installed, $pkg; + } + else { + push @modules, $pkg, $ver; + } + } + + return @installed unless @modules; # nothing to do + return @installed if _check_lock(); # defer to the CPAN shell + + print "*** Installing dependencies...\n"; + + return unless _connected_to('cpan.org'); + + my %args = @config; + my %failed; + local *FAILED; + if ( $args{do_once} and open( FAILED, '.#autoinstall.failed' ) ) { + while () { chomp; $failed{$_}++ } + close FAILED; + + my @newmod; + while ( my ( $k, $v ) = splice( @modules, 0, 2 ) ) { + push @newmod, ( $k => $v ) unless $failed{$k}; + } + @modules = @newmod; + } + + if ( _has_cpanplus() and not $ENV{PERL_AUTOINSTALL_PREFER_CPAN} ) { + _install_cpanplus( \@modules, \@config ); + } else { + _install_cpan( \@modules, \@config ); + } + + print "*** $class installation finished.\n"; + + # see if we have successfully installed them + while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { + if ( _version_cmp( _load($pkg), $ver ) >= 0 ) { + push @installed, $pkg; + } + elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) { + print FAILED "$pkg\n"; + } + } + + close FAILED if $args{do_once}; + + return @installed; +} + +sub _install_cpanplus { + my @modules = @{ +shift }; + my @config = _cpanplus_config( @{ +shift } ); + my $installed = 0; + + require CPANPLUS::Backend; + my $cp = CPANPLUS::Backend->new; + my $conf = $cp->configure_object; + + return unless $conf->can('conf') # 0.05x+ with "sudo" support + or _can_write($conf->_get_build('base')); # 0.04x + + # if we're root, set UNINST=1 to avoid trouble unless user asked for it. + my $makeflags = $conf->get_conf('makeflags') || ''; + if ( UNIVERSAL::isa( $makeflags, 'HASH' ) ) { + # 0.03+ uses a hashref here + $makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST}; + + } else { + # 0.02 and below uses a scalar + $makeflags = join( ' ', split( ' ', $makeflags ), 'UNINST=1' ) + if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } ); + + } + $conf->set_conf( makeflags => $makeflags ); + $conf->set_conf( prereqs => 1 ); + + + + while ( my ( $key, $val ) = splice( @config, 0, 2 ) ) { + $conf->set_conf( $key, $val ); + } + + my $modtree = $cp->module_tree; + while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { + print "*** Installing $pkg...\n"; + + MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall; + + my $success; + my $obj = $modtree->{$pkg}; + + if ( $obj and _version_cmp( $obj->{version}, $ver ) >= 0 ) { + my $pathname = $pkg; + $pathname =~ s/::/\\W/; + + foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) { + delete $INC{$inc}; + } + + my $rv = $cp->install( modules => [ $obj->{module} ] ); + + if ( $rv and ( $rv->{ $obj->{module} } or $rv->{ok} ) ) { + print "*** $pkg successfully installed.\n"; + $success = 1; + } else { + print "*** $pkg installation cancelled.\n"; + $success = 0; + } + + $installed += $success; + } else { + print << "."; +*** Could not find a version $ver or above for $pkg; skipping. +. + } + + MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall; + } + + return $installed; +} + +sub _cpanplus_config { + my @config = (); + while ( @_ ) { + my ($key, $value) = (shift(), shift()); + if ( $key eq 'prerequisites_policy' ) { + if ( $value eq 'follow' ) { + $value = CPANPLUS::Internals::Constants::PREREQ_INSTALL(); + } elsif ( $value eq 'ask' ) { + $value = CPANPLUS::Internals::Constants::PREREQ_ASK(); + } elsif ( $value eq 'ignore' ) { + $value = CPANPLUS::Internals::Constants::PREREQ_IGNORE(); + } else { + die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n"; + } + } else { + die "*** Cannot convert option $key to CPANPLUS version.\n"; + } + } + return @config; +} + +sub _install_cpan { + my @modules = @{ +shift }; + my @config = @{ +shift }; + my $installed = 0; + my %args; + + _load_cpan(); + require Config; + + if (CPAN->VERSION < 1.80) { + # no "sudo" support, probe for writableness + return unless _can_write( MM->catfile( $CPAN::Config->{cpan_home}, 'sources' ) ) + and _can_write( $Config::Config{sitelib} ); + } + + # if we're root, set UNINST=1 to avoid trouble unless user asked for it. + my $makeflags = $CPAN::Config->{make_install_arg} || ''; + $CPAN::Config->{make_install_arg} = + join( ' ', split( ' ', $makeflags ), 'UNINST=1' ) + if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } ); + + # don't show start-up info + $CPAN::Config->{inhibit_startup_message} = 1; + + # set additional options + while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) { + ( $args{$opt} = $arg, next ) + if $opt =~ /^force$/; # pseudo-option + $CPAN::Config->{$opt} = $arg; + } + + local $CPAN::Config->{prerequisites_policy} = 'follow'; + + while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { + MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall; + + print "*** Installing $pkg...\n"; + + my $obj = CPAN::Shell->expand( Module => $pkg ); + my $success = 0; + + if ( $obj and _version_cmp( $obj->cpan_version, $ver ) >= 0 ) { + my $pathname = $pkg; + $pathname =~ s/::/\\W/; + + foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) { + delete $INC{$inc}; + } + + my $rv = $args{force} ? CPAN::Shell->force( install => $pkg ) + : CPAN::Shell->install($pkg); + $rv ||= eval { + $CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, ) + ->{install} + if $CPAN::META; + }; + + if ( $rv eq 'YES' ) { + print "*** $pkg successfully installed.\n"; + $success = 1; + } + else { + print "*** $pkg installation failed.\n"; + $success = 0; + } + + $installed += $success; + } + else { + print << "."; +*** Could not find a version $ver or above for $pkg; skipping. +. + } + + MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall; + } + + return $installed; +} + +sub _has_cpanplus { + return ( + $HasCPANPLUS = ( + $INC{'CPANPLUS/Config.pm'} + or _load('CPANPLUS::Shell::Default') + ) + ); +} + +# make guesses on whether we're under the CPAN installation directory +sub _under_cpan { + require Cwd; + require File::Spec; + + my $cwd = File::Spec->canonpath( Cwd::cwd() ); + my $cpan = File::Spec->canonpath( $CPAN::Config->{cpan_home} ); + + return ( index( $cwd, $cpan ) > -1 ); +} + +sub _update_to { + my $class = __PACKAGE__; + my $ver = shift; + + return + if _version_cmp( _load($class), $ver ) >= 0; # no need to upgrade + + if ( + _prompt( "==> A newer version of $class ($ver) is required. Install?", + 'y' ) =~ /^[Nn]/ + ) + { + die "*** Please install $class $ver manually.\n"; + } + + print << "."; +*** Trying to fetch it from CPAN... +. + + # install ourselves + _load($class) and return $class->import(@_) + if $class->install( [], $class, $ver ); + + print << '.'; exit 1; + +*** Cannot bootstrap myself. :-( Installation terminated. +. +} + +# check if we're connected to some host, using inet_aton +sub _connected_to { + my $site = shift; + + return ( + ( _load('Socket') and Socket::inet_aton($site) ) or _prompt( + qq( +*** Your host cannot resolve the domain name '$site', which + probably means the Internet connections are unavailable. +==> Should we try to install the required module(s) anyway?), 'n' + ) =~ /^[Yy]/ + ); +} + +# check if a directory is writable; may create it on demand +sub _can_write { + my $path = shift; + mkdir( $path, 0755 ) unless -e $path; + + return 1 if -w $path; + + print << "."; +*** You are not allowed to write to the directory '$path'; + the installation may fail due to insufficient permissions. +. + + if ( + eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt( + qq( +==> Should we try to re-execute the autoinstall process with 'sudo'?), + ((-t STDIN) ? 'y' : 'n') + ) =~ /^[Yy]/ + ) + { + + # try to bootstrap ourselves from sudo + print << "."; +*** Trying to re-execute the autoinstall process with 'sudo'... +. + my $missing = join( ',', @Missing ); + my $config = join( ',', + UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) + if $Config; + + return + unless system( 'sudo', $^X, $0, "--config=$config", + "--installdeps=$missing" ); + + print << "."; +*** The 'sudo' command exited with error! Resuming... +. + } + + return _prompt( + qq( +==> Should we try to install the required module(s) anyway?), 'n' + ) =~ /^[Yy]/; +} + +# load a module and return the version it reports +sub _load { + my $mod = pop; # class/instance doesn't matter + my $file = $mod; + + $file =~ s|::|/|g; + $file .= '.pm'; + + local $@; + return eval { require $file; $mod->VERSION } || ( $@ ? undef: 0 ); +} + +# Load CPAN.pm and it's configuration +sub _load_cpan { + return if $CPAN::VERSION and $CPAN::Config and not @_; + require CPAN; + + # CPAN-1.82+ adds CPAN::Config::AUTOLOAD to redirect to + # CPAN::HandleConfig->load. CPAN reports that the redirection + # is deprecated in a warning printed at the user. + + # CPAN-1.81 expects CPAN::HandleConfig->load, does not have + # $CPAN::HandleConfig::VERSION but cannot handle + # CPAN::Config->load + + # Which "versions expect CPAN::Config->load? + + if ( $CPAN::HandleConfig::VERSION + || CPAN::HandleConfig->can('load') + ) { + # Newer versions of CPAN have a HandleConfig module + CPAN::HandleConfig->load; + } else { + # Older versions had the load method in Config directly + CPAN::Config->load; + } +} + +# compare two versions, either use Sort::Versions or plain comparison +# return values same as <=> +sub _version_cmp { + my ( $cur, $min ) = @_; + return -1 unless defined $cur; # if 0 keep comparing + return 1 unless $min; + + $cur =~ s/\s+$//; + + # check for version numbers that are not in decimal format + if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) { + if ( ( $version::VERSION or defined( _load('version') )) and + version->can('new') + ) { + + # use version.pm if it is installed. + return version->new($cur) <=> version->new($min); + } + elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) ) + { + + # use Sort::Versions as the sorting algorithm for a.b.c versions + return Sort::Versions::versioncmp( $cur, $min ); + } + + warn "Cannot reliably compare non-decimal formatted versions.\n" + . "Please install version.pm or Sort::Versions.\n"; + } + + # plain comparison + local $^W = 0; # shuts off 'not numeric' bugs + return $cur <=> $min; +} + +# nothing; this usage is deprecated. +sub main::PREREQ_PM { return {}; } + +sub _make_args { + my %args = @_; + + $args{PREREQ_PM} = { %{ $args{PREREQ_PM} || {} }, @Existing, @Missing } + if $UnderCPAN or $TestOnly; + + if ( $args{EXE_FILES} and -e 'MANIFEST' ) { + require ExtUtils::Manifest; + my $manifest = ExtUtils::Manifest::maniread('MANIFEST'); + + $args{EXE_FILES} = + [ grep { exists $manifest->{$_} } @{ $args{EXE_FILES} } ]; + } + + $args{test}{TESTS} ||= 't/*.t'; + $args{test}{TESTS} = join( ' ', + grep { !exists( $DisabledTests{$_} ) } + map { glob($_) } split( /\s+/, $args{test}{TESTS} ) ); + + my $missing = join( ',', @Missing ); + my $config = + join( ',', UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) + if $Config; + + $PostambleActions = ( + ($missing and not $UnderCPAN) + ? "\$(PERL) $0 --config=$config --installdeps=$missing" + : "\$(NOECHO) \$(NOOP)" + ); + + return %args; +} + +# a wrapper to ExtUtils::MakeMaker::WriteMakefile +sub Write { + require Carp; + Carp::croak "WriteMakefile: Need even number of args" if @_ % 2; + + if ($CheckOnly) { + print << "."; +*** Makefile not written in check-only mode. +. + return; + } + + my %args = _make_args(@_); + + no strict 'refs'; + + $PostambleUsed = 0; + local *MY::postamble = \&postamble unless defined &MY::postamble; + ExtUtils::MakeMaker::WriteMakefile(%args); + + print << "." unless $PostambleUsed; +*** WARNING: Makefile written with customized MY::postamble() without + including contents from Module::AutoInstall::postamble() -- + auto installation features disabled. Please contact the author. +. + + return 1; +} + +sub postamble { + $PostambleUsed = 1; + + return <<"END_MAKE"; + +config :: installdeps +\t\$(NOECHO) \$(NOOP) + +checkdeps :: +\t\$(PERL) $0 --checkdeps + +installdeps :: +\t$PostambleActions + +END_MAKE + +} + +1; + +__END__ + +#line 1069 diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm new file mode 100644 index 0000000..ac76107 --- /dev/null +++ b/inc/Module/Install.pm @@ -0,0 +1,445 @@ +#line 1 +package Module::Install; + +# For any maintainers: +# The load order for Module::Install is a bit magic. +# It goes something like this... +# +# IF ( host has Module::Install installed, creating author mode ) { +# 1. Makefile.PL calls "use inc::Module::Install" +# 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install +# 3. The installed version of inc::Module::Install loads +# 4. inc::Module::Install calls "require Module::Install" +# 5. The ./inc/ version of Module::Install loads +# } ELSE { +# 1. Makefile.PL calls "use inc::Module::Install" +# 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install +# 3. The ./inc/ version of Module::Install loads +# } + +use 5.005; +use strict 'vars'; + +use vars qw{$VERSION $MAIN}; +BEGIN { + # All Module::Install core packages now require synchronised versions. + # This will be used to ensure we don't accidentally load old or + # different versions of modules. + # This is not enforced yet, but will be some time in the next few + # releases once we can make sure it won't clash with custom + # Module::Install extensions. + $VERSION = '0.93'; + + # Storage for the pseudo-singleton + $MAIN = undef; + + *inc::Module::Install::VERSION = *VERSION; + @inc::Module::Install::ISA = __PACKAGE__; + +} + + + + + +# Whether or not inc::Module::Install is actually loaded, the +# $INC{inc/Module/Install.pm} is what will still get set as long as +# the caller loaded module this in the documented manner. +# If not set, the caller may NOT have loaded the bundled version, and thus +# they may not have a MI version that works with the Makefile.PL. This would +# result in false errors or unexpected behaviour. And we don't want that. +my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; +unless ( $INC{$file} ) { die <<"END_DIE" } + +Please invoke ${\__PACKAGE__} with: + + use inc::${\__PACKAGE__}; + +not: + + use ${\__PACKAGE__}; + +END_DIE + + + + + +# If the script that is loading Module::Install is from the future, +# then make will detect this and cause it to re-run over and over +# again. This is bad. Rather than taking action to touch it (which +# is unreliable on some platforms and requires write permissions) +# for now we should catch this and refuse to run. +if ( -f $0 ) { + my $s = (stat($0))[9]; + + # If the modification time is only slightly in the future, + # sleep briefly to remove the problem. + my $a = $s - time; + if ( $a > 0 and $a < 5 ) { sleep 5 } + + # Too far in the future, throw an error. + my $t = time; + if ( $s > $t ) { die <<"END_DIE" } + +Your installer $0 has a modification time in the future ($s > $t). + +This is known to create infinite loops in make. + +Please correct this, then run $0 again. + +END_DIE +} + + + + + +# Build.PL was formerly supported, but no longer is due to excessive +# difficulty in implementing every single feature twice. +if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } + +Module::Install no longer supports Build.PL. + +It was impossible to maintain duel backends, and has been deprecated. + +Please remove all Build.PL files and only use the Makefile.PL installer. + +END_DIE + + + + + +# To save some more typing in Module::Install installers, every... +# use inc::Module::Install +# ...also acts as an implicit use strict. +$^H |= strict::bits(qw(refs subs vars)); + + + + + +use Cwd (); +use File::Find (); +use File::Path (); +use FindBin; + +sub autoload { + my $self = shift; + my $who = $self->_caller; + my $cwd = Cwd::cwd(); + my $sym = "${who}::AUTOLOAD"; + $sym->{$cwd} = sub { + my $pwd = Cwd::cwd(); + if ( my $code = $sym->{$pwd} ) { + # Delegate back to parent dirs + goto &$code unless $cwd eq $pwd; + } + $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym"; + my $method = $1; + if ( uc($method) eq $method ) { + # Do nothing + return; + } elsif ( $method =~ /^_/ and $self->can($method) ) { + # Dispatch to the root M:I class + return $self->$method(@_); + } + + # Dispatch to the appropriate plugin + unshift @_, ( $self, $1 ); + goto &{$self->can('call')}; + }; +} + +sub import { + my $class = shift; + my $self = $class->new(@_); + my $who = $self->_caller; + + unless ( -f $self->{file} ) { + require "$self->{path}/$self->{dispatch}.pm"; + File::Path::mkpath("$self->{prefix}/$self->{author}"); + $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); + $self->{admin}->init; + @_ = ($class, _self => $self); + goto &{"$self->{name}::import"}; + } + + *{"${who}::AUTOLOAD"} = $self->autoload; + $self->preload; + + # Unregister loader and worker packages so subdirs can use them again + delete $INC{"$self->{file}"}; + delete $INC{"$self->{path}.pm"}; + + # Save to the singleton + $MAIN = $self; + + return 1; +} + +sub preload { + my $self = shift; + unless ( $self->{extensions} ) { + $self->load_extensions( + "$self->{prefix}/$self->{path}", $self + ); + } + + my @exts = @{$self->{extensions}}; + unless ( @exts ) { + @exts = $self->{admin}->load_all_extensions; + } + + my %seen; + foreach my $obj ( @exts ) { + while (my ($method, $glob) = each %{ref($obj) . '::'}) { + next unless $obj->can($method); + next if $method =~ /^_/; + next if $method eq uc($method); + $seen{$method}++; + } + } + + my $who = $self->_caller; + foreach my $name ( sort keys %seen ) { + *{"${who}::$name"} = sub { + ${"${who}::AUTOLOAD"} = "${who}::$name"; + goto &{"${who}::AUTOLOAD"}; + }; + } +} + +sub new { + my ($class, %args) = @_; + + # ignore the prefix on extension modules built from top level. + my $base_path = Cwd::abs_path($FindBin::Bin); + unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) { + delete $args{prefix}; + } + + return $args{_self} if $args{_self}; + + $args{dispatch} ||= 'Admin'; + $args{prefix} ||= 'inc'; + $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); + $args{bundle} ||= 'inc/BUNDLES'; + $args{base} ||= $base_path; + $class =~ s/^\Q$args{prefix}\E:://; + $args{name} ||= $class; + $args{version} ||= $class->VERSION; + unless ( $args{path} ) { + $args{path} = $args{name}; + $args{path} =~ s!::!/!g; + } + $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; + $args{wrote} = 0; + + bless( \%args, $class ); +} + +sub call { + my ($self, $method) = @_; + my $obj = $self->load($method) or return; + splice(@_, 0, 2, $obj); + goto &{$obj->can($method)}; +} + +sub load { + my ($self, $method) = @_; + + $self->load_extensions( + "$self->{prefix}/$self->{path}", $self + ) unless $self->{extensions}; + + foreach my $obj (@{$self->{extensions}}) { + return $obj if $obj->can($method); + } + + my $admin = $self->{admin} or die <<"END_DIE"; +The '$method' method does not exist in the '$self->{prefix}' path! +Please remove the '$self->{prefix}' directory and run $0 again to load it. +END_DIE + + my $obj = $admin->load($method, 1); + push @{$self->{extensions}}, $obj; + + $obj; +} + +sub load_extensions { + my ($self, $path, $top) = @_; + + unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { + unshift @INC, $self->{prefix}; + } + + foreach my $rv ( $self->find_extensions($path) ) { + my ($file, $pkg) = @{$rv}; + next if $self->{pathnames}{$pkg}; + + local $@; + my $new = eval { require $file; $pkg->can('new') }; + unless ( $new ) { + warn $@ if $@; + next; + } + $self->{pathnames}{$pkg} = delete $INC{$file}; + push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); + } + + $self->{extensions} ||= []; +} + +sub find_extensions { + my ($self, $path) = @_; + + my @found; + File::Find::find( sub { + my $file = $File::Find::name; + return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; + my $subpath = $1; + return if lc($subpath) eq lc($self->{dispatch}); + + $file = "$self->{path}/$subpath.pm"; + my $pkg = "$self->{name}::$subpath"; + $pkg =~ s!/!::!g; + + # If we have a mixed-case package name, assume case has been preserved + # correctly. Otherwise, root through the file to locate the case-preserved + # version of the package name. + if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { + my $content = Module::Install::_read($subpath . '.pm'); + my $in_pod = 0; + foreach ( split //, $content ) { + $in_pod = 1 if /^=\w/; + $in_pod = 0 if /^=cut/; + next if ($in_pod || /^=cut/); # skip pod text + next if /^\s*#/; # and comments + if ( m/^\s*package\s+($pkg)\s*;/i ) { + $pkg = $1; + last; + } + } + } + + push @found, [ $file, $pkg ]; + }, $path ) if -d $path; + + @found; +} + + + + + +##################################################################### +# Common Utility Functions + +sub _caller { + my $depth = 0; + my $call = caller($depth); + while ( $call eq __PACKAGE__ ) { + $depth++; + $call = caller($depth); + } + return $call; +} + +# Done in evals to avoid confusing Perl::MinimumVersion +eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; +sub _read { + local *FH; + open( FH, '<', $_[0] ) or die "open($_[0]): $!"; + my $string = do { local $/; }; + close FH or die "close($_[0]): $!"; + return $string; +} +END_NEW +sub _read { + local *FH; + open( FH, "< $_[0]" ) or die "open($_[0]): $!"; + my $string = do { local $/; }; + close FH or die "close($_[0]): $!"; + return $string; +} +END_OLD + +sub _readperl { + my $string = Module::Install::_read($_[0]); + $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; + $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; + $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; + return $string; +} + +sub _readpod { + my $string = Module::Install::_read($_[0]); + $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; + return $string if $_[0] =~ /\.pod\z/; + $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; + $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; + $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; + $string =~ s/^\n+//s; + return $string; +} + +# Done in evals to avoid confusing Perl::MinimumVersion +eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; +sub _write { + local *FH; + open( FH, '>', $_[0] ) or die "open($_[0]): $!"; + foreach ( 1 .. $#_ ) { + print FH $_[$_] or die "print($_[0]): $!"; + } + close FH or die "close($_[0]): $!"; +} +END_NEW +sub _write { + local *FH; + open( FH, "> $_[0]" ) or die "open($_[0]): $!"; + foreach ( 1 .. $#_ ) { + print FH $_[$_] or die "print($_[0]): $!"; + } + close FH or die "close($_[0]): $!"; +} +END_OLD + +# _version is for processing module versions (eg, 1.03_05) not +# Perl versions (eg, 5.8.1). +sub _version ($) { + my $s = shift || 0; + my $d =()= $s =~ /(\.)/g; + if ( $d >= 2 ) { + # Normalise multipart versions + $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; + } + $s =~ s/^(\d+)\.?//; + my $l = $1 || 0; + my @v = map { + $_ . '0' x (3 - length $_) + } $s =~ /(\d{1,3})\D?/g; + $l = $l . '.' . join '', @v if @v; + return $l + 0; +} + +sub _cmp ($$) { + _version($_[0]) <=> _version($_[1]); +} + +# Cloned from Params::Util::_CLASS +sub _CLASS ($) { + ( + defined $_[0] + and + ! ref $_[0] + and + $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s + ) ? $_[0] : undef; +} + +1; + +# Copyright 2008 - 2010 Adam Kennedy. diff --git a/inc/Module/Install/AutoInstall.pm b/inc/Module/Install/AutoInstall.pm new file mode 100644 index 0000000..09af6d4 --- /dev/null +++ b/inc/Module/Install/AutoInstall.pm @@ -0,0 +1,61 @@ +#line 1 +package Module::Install::AutoInstall; + +use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +sub AutoInstall { $_[0] } + +sub run { + my $self = shift; + $self->auto_install_now(@_); +} + +sub write { + my $self = shift; + $self->auto_install(@_); +} + +sub auto_install { + my $self = shift; + return if $self->{done}++; + + # Flatten array of arrays into a single array + my @core = map @$_, map @$_, grep ref, + $self->build_requires, $self->requires; + + my @config = @_; + + # We'll need Module::AutoInstall + $self->include('Module::AutoInstall'); + require Module::AutoInstall; + + Module::AutoInstall->import( + (@config ? (-config => \@config) : ()), + (@core ? (-core => \@core) : ()), + $self->features, + ); + + $self->makemaker_args( Module::AutoInstall::_make_args() ); + + my $class = ref($self); + $self->postamble( + "# --- $class section:\n" . + Module::AutoInstall::postamble() + ); +} + +sub auto_install_now { + my $self = shift; + $self->auto_install(@_); + Module::AutoInstall::do_install(); +} + +1; diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm new file mode 100644 index 0000000..7f3210b --- /dev/null +++ b/inc/Module/Install/Base.pm @@ -0,0 +1,78 @@ +#line 1 +package Module::Install::Base; + +use strict 'vars'; +use vars qw{$VERSION}; +BEGIN { + $VERSION = '0.93'; +} + +# Suspend handler for "redefined" warnings +BEGIN { + my $w = $SIG{__WARN__}; + $SIG{__WARN__} = sub { $w }; +} + +#line 42 + +sub new { + my $class = shift; + unless ( defined &{"${class}::call"} ) { + *{"${class}::call"} = sub { shift->_top->call(@_) }; + } + unless ( defined &{"${class}::load"} ) { + *{"${class}::load"} = sub { shift->_top->load(@_) }; + } + bless { @_ }, $class; +} + +#line 61 + +sub AUTOLOAD { + local $@; + my $func = eval { shift->_top->autoload } or return; + goto &$func; +} + +#line 75 + +sub _top { + $_[0]->{_top}; +} + +#line 90 + +sub admin { + $_[0]->_top->{admin} + or + Module::Install::Base::FakeAdmin->new; +} + +#line 106 + +sub is_admin { + $_[0]->admin->VERSION; +} + +sub DESTROY {} + +package Module::Install::Base::FakeAdmin; + +my $fake; + +sub new { + $fake ||= bless(\@_, $_[0]); +} + +sub AUTOLOAD {} + +sub DESTROY {} + +# Restore warning handler +BEGIN { + $SIG{__WARN__} = $SIG{__WARN__}->(); +} + +1; + +#line 154 diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm new file mode 100644 index 0000000..6194337 --- /dev/null +++ b/inc/Module/Install/Can.pm @@ -0,0 +1,81 @@ +#line 1 +package Module::Install::Can; + +use strict; +use Config (); +use File::Spec (); +use ExtUtils::MakeMaker (); +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +# check if we can load some module +### Upgrade this to not have to load the module if possible +sub can_use { + my ($self, $mod, $ver) = @_; + $mod =~ s{::|\\}{/}g; + $mod .= '.pm' unless $mod =~ /\.pm$/i; + + my $pkg = $mod; + $pkg =~ s{/}{::}g; + $pkg =~ s{\.pm$}{}i; + + local $@; + eval { require $mod; $pkg->VERSION($ver || 0); 1 }; +} + +# check if we can run some command +sub can_run { + my ($self, $cmd) = @_; + + my $_cmd = $cmd; + return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); + + for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { + next if $dir eq ''; + my $abs = File::Spec->catfile($dir, $_[1]); + return $abs if (-x $abs or $abs = MM->maybe_command($abs)); + } + + return; +} + +# can we locate a (the) C compiler +sub can_cc { + my $self = shift; + my @chunks = split(/ /, $Config::Config{cc}) or return; + + # $Config{cc} may contain args; try to find out the program part + while (@chunks) { + return $self->can_run("@chunks") || (pop(@chunks), next); + } + + return; +} + +# Fix Cygwin bug on maybe_command(); +if ( $^O eq 'cygwin' ) { + require ExtUtils::MM_Cygwin; + require ExtUtils::MM_Win32; + if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { + *ExtUtils::MM_Cygwin::maybe_command = sub { + my ($self, $file) = @_; + if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { + ExtUtils::MM_Win32->maybe_command($file); + } else { + ExtUtils::MM_Unix->maybe_command($file); + } + } + } +} + +1; + +__END__ + +#line 156 diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm new file mode 100644 index 0000000..27fcb25 --- /dev/null +++ b/inc/Module/Install/Fetch.pm @@ -0,0 +1,93 @@ +#line 1 +package Module::Install::Fetch; + +use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +sub get_file { + my ($self, %args) = @_; + my ($scheme, $host, $path, $file) = + $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; + + if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { + $args{url} = $args{ftp_url} + or (warn("LWP support unavailable!\n"), return); + ($scheme, $host, $path, $file) = + $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; + } + + $|++; + print "Fetching '$file' from $host... "; + + unless (eval { require Socket; Socket::inet_aton($host) }) { + warn "'$host' resolve failed!\n"; + return; + } + + return unless $scheme eq 'ftp' or $scheme eq 'http'; + + require Cwd; + my $dir = Cwd::getcwd(); + chdir $args{local_dir} or return if exists $args{local_dir}; + + if (eval { require LWP::Simple; 1 }) { + LWP::Simple::mirror($args{url}, $file); + } + elsif (eval { require Net::FTP; 1 }) { eval { + # use Net::FTP to get past firewall + my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); + $ftp->login("anonymous", 'anonymous@example.com'); + $ftp->cwd($path); + $ftp->binary; + $ftp->get($file) or (warn("$!\n"), return); + $ftp->quit; + } } + elsif (my $ftp = $self->can_run('ftp')) { eval { + # no Net::FTP, fallback to ftp.exe + require FileHandle; + my $fh = FileHandle->new; + + local $SIG{CHLD} = 'IGNORE'; + unless ($fh->open("|$ftp -n")) { + warn "Couldn't open ftp: $!\n"; + chdir $dir; return; + } + + my @dialog = split(/\n/, <<"END_FTP"); +open $host +user anonymous anonymous\@example.com +cd $path +binary +get $file $file +quit +END_FTP + foreach (@dialog) { $fh->print("$_\n") } + $fh->close; + } } + else { + warn "No working 'ftp' program available!\n"; + chdir $dir; return; + } + + unless (-f $file) { + warn "Fetching failed: $@\n"; + chdir $dir; return; + } + + return if exists $args{size} and -s $file != $args{size}; + system($args{run}) if exists $args{run}; + unlink($file) if $args{remove}; + + print(((!exists $args{check_for} or -e $args{check_for}) + ? "done!" : "failed! ($!)"), "\n"); + chdir $dir; return !$?; +} + +1; diff --git a/inc/Module/Install/Include.pm b/inc/Module/Install/Include.pm new file mode 100644 index 0000000..dc7881f --- /dev/null +++ b/inc/Module/Install/Include.pm @@ -0,0 +1,34 @@ +#line 1 +package Module::Install::Include; + +use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +sub include { + shift()->admin->include(@_); +} + +sub include_deps { + shift()->admin->include_deps(@_); +} + +sub auto_include { + shift()->admin->auto_include(@_); +} + +sub auto_include_deps { + shift()->admin->auto_include_deps(@_); +} + +sub auto_include_dependent_dists { + shift()->admin->auto_include_dependent_dists(@_); +} + +1; diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm new file mode 100644 index 0000000..6e4dc3d --- /dev/null +++ b/inc/Module/Install/Makefile.pm @@ -0,0 +1,309 @@ +#line 1 +package Module::Install::Makefile; + +use strict 'vars'; +use ExtUtils::MakeMaker (); +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +sub Makefile { $_[0] } + +my %seen = (); + +sub prompt { + shift; + + # Infinite loop protection + my @c = caller(); + if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { + die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; + } + + # In automated testing, always use defaults + if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) { + local $ENV{PERL_MM_USE_DEFAULT} = 1; + goto &ExtUtils::MakeMaker::prompt; + } else { + goto &ExtUtils::MakeMaker::prompt; + } +} + +# Store a cleaned up version of the MakeMaker version, +# since we need to behave differently in a variety of +# ways based on the MM version. +my $makemaker = eval $ExtUtils::MakeMaker::VERSION; + +# If we are passed a param, do a "newer than" comparison. +# Otherwise, just return the MakeMaker version. +sub makemaker { + ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 +} + +sub makemaker_args { + my $self = shift; + my $args = ( $self->{makemaker_args} ||= {} ); + %$args = ( %$args, @_ ); + return $args; +} + +# For mm args that take multiple space-seperated args, +# append an argument to the current list. +sub makemaker_append { + my $self = shift; + my $name = shift; + my $args = $self->makemaker_args; + $args->{name} = defined $args->{$name} + ? join( ' ', $args->{name}, @_ ) + : join( ' ', @_ ); +} + +sub build_subdirs { + my $self = shift; + my $subdirs = $self->makemaker_args->{DIR} ||= []; + for my $subdir (@_) { + push @$subdirs, $subdir; + } +} + +sub clean_files { + my $self = shift; + my $clean = $self->makemaker_args->{clean} ||= {}; + %$clean = ( + %$clean, + FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), + ); +} + +sub realclean_files { + my $self = shift; + my $realclean = $self->makemaker_args->{realclean} ||= {}; + %$realclean = ( + %$realclean, + FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), + ); +} + +sub libs { + my $self = shift; + my $libs = ref $_[0] ? shift : [ shift ]; + $self->makemaker_args( LIBS => $libs ); +} + +sub inc { + my $self = shift; + $self->makemaker_args( INC => shift ); +} + +my %test_dir = (); + +sub _wanted_t { + /\.t$/ and -f $_ and $test_dir{$File::Find::dir} = 1; +} + +sub tests_recursive { + my $self = shift; + if ( $self->tests ) { + die "tests_recursive will not work if tests are already defined"; + } + my $dir = shift || 't'; + unless ( -d $dir ) { + die "tests_recursive dir '$dir' does not exist"; + } + %test_dir = (); + require File::Find; + File::Find::find( \&_wanted_t, $dir ); + if ( -d 'xt' and ($ENV{RELEASE_TESTING} or $self->author) ) { + File::Find::find( \&_wanted_t, 'xt' ); + } + $self->tests( join ' ', map { "$_/*.t" } sort keys %test_dir ); +} + +sub write { + my $self = shift; + die "&Makefile->write() takes no arguments\n" if @_; + + # Check the current Perl version + my $perl_version = $self->perl_version; + if ( $perl_version ) { + eval "use $perl_version; 1" + or die "ERROR: perl: Version $] is installed, " + . "but we need version >= $perl_version"; + } + + # Make sure we have a new enough MakeMaker + require ExtUtils::MakeMaker; + + if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { + # MakeMaker can complain about module versions that include + # an underscore, even though its own version may contain one! + # Hence the funny regexp to get rid of it. See RT #35800 + # for details. + my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/; + $self->build_requires( 'ExtUtils::MakeMaker' => $v ); + $self->configure_requires( 'ExtUtils::MakeMaker' => $v ); + } else { + # Allow legacy-compatibility with 5.005 by depending on the + # most recent EU:MM that supported 5.005. + $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 ); + $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 ); + } + + # Generate the MakeMaker params + my $args = $self->makemaker_args; + $args->{DISTNAME} = $self->name; + $args->{NAME} = $self->module_name || $self->name; + $args->{VERSION} = $self->version; + $args->{NAME} =~ s/-/::/g; + $DB::single = 1; + if ( $self->tests ) { + $args->{test} = { TESTS => $self->tests }; + } elsif ( -d 'xt' and ($self->author or $ENV{RELEASE_TESTING}) ) { + $args->{test} = { + TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), + }; + } + if ( $] >= 5.005 ) { + $args->{ABSTRACT} = $self->abstract; + $args->{AUTHOR} = $self->author; + } + if ( $self->makemaker(6.10) ) { + $args->{NO_META} = 1; + #$args->{NO_MYMETA} = 1; + } + if ( $self->makemaker(6.17) and $self->sign ) { + $args->{SIGN} = 1; + } + unless ( $self->is_admin ) { + delete $args->{SIGN}; + } + + my $prereq = ($args->{PREREQ_PM} ||= {}); + %$prereq = ( %$prereq, + map { @$_ } # flatten [module => version] + map { @$_ } + grep $_, + ($self->requires) + ); + + # Remove any reference to perl, PREREQ_PM doesn't support it + delete $args->{PREREQ_PM}->{perl}; + + # Merge both kinds of requires into BUILD_REQUIRES + my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); + %$build_prereq = ( %$build_prereq, + map { @$_ } # flatten [module => version] + map { @$_ } + grep $_, + ($self->configure_requires, $self->build_requires) + ); + + # Remove any reference to perl, BUILD_REQUIRES doesn't support it + delete $args->{BUILD_REQUIRES}->{perl}; + + # Delete bundled dists from prereq_pm + my $subdirs = ($args->{DIR} ||= []); + if ($self->bundles) { + foreach my $bundle (@{ $self->bundles }) { + my ($file, $dir) = @$bundle; + push @$subdirs, $dir if -d $dir; + delete $build_prereq->{$file}; #Delete from build prereqs only + } + } + + unless ( $self->makemaker('6.55_03') ) { + %$prereq = (%$prereq,%$build_prereq); + delete $args->{BUILD_REQUIRES}; + } + + if ( my $perl_version = $self->perl_version ) { + eval "use $perl_version; 1" + or die "ERROR: perl: Version $] is installed, " + . "but we need version >= $perl_version"; + + if ( $self->makemaker(6.48) ) { + $args->{MIN_PERL_VERSION} = $perl_version; + } + } + + $args->{INSTALLDIRS} = $self->installdirs; + + my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_})} keys %$args; + + my $user_preop = delete $args{dist}->{PREOP}; + if (my $preop = $self->admin->preop($user_preop)) { + foreach my $key ( keys %$preop ) { + $args{dist}->{$key} = $preop->{$key}; + } + } + + my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); + $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); +} + +sub fix_up_makefile { + my $self = shift; + my $makefile_name = shift; + my $top_class = ref($self->_top) || ''; + my $top_version = $self->_top->VERSION || ''; + + my $preamble = $self->preamble + ? "# Preamble by $top_class $top_version\n" + . $self->preamble + : ''; + my $postamble = "# Postamble by $top_class $top_version\n" + . ($self->postamble || ''); + + local *MAKEFILE; + open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; + my $makefile = do { local $/; }; + close MAKEFILE or die $!; + + $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; + $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; + $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; + $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; + $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; + + # Module::Install will never be used to build the Core Perl + # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks + # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist + $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; + #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; + + # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. + $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; + + # XXX - This is currently unused; not sure if it breaks other MM-users + # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; + + open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; + print MAKEFILE "$preamble$makefile$postamble" or die $!; + close MAKEFILE or die $!; + + 1; +} + +sub preamble { + my ($self, $text) = @_; + $self->{preamble} = $text . $self->{preamble} if defined $text; + $self->{preamble}; +} + +sub postamble { + my ($self, $text) = @_; + $self->{postamble} ||= $self->admin->postamble; + $self->{postamble} .= $text if defined $text; + $self->{postamble} +} + +1; + +__END__ + +#line 435 diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm new file mode 100644 index 0000000..93dfc8a --- /dev/null +++ b/inc/Module/Install/Metadata.pm @@ -0,0 +1,648 @@ +#line 1 +package Module::Install::Metadata; + +use strict 'vars'; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +my @boolean_keys = qw{ + sign +}; + +my @scalar_keys = qw{ + name + module_name + abstract + author + version + distribution_type + tests + installdirs +}; + +my @tuple_keys = qw{ + configure_requires + build_requires + requires + recommends + bundles + resources +}; + +my @resource_keys = qw{ + homepage + bugtracker + repository +}; + +my @array_keys = qw{ + keywords +}; + +sub Meta { shift } +sub Meta_BooleanKeys { @boolean_keys } +sub Meta_ScalarKeys { @scalar_keys } +sub Meta_TupleKeys { @tuple_keys } +sub Meta_ResourceKeys { @resource_keys } +sub Meta_ArrayKeys { @array_keys } + +foreach my $key ( @boolean_keys ) { + *$key = sub { + my $self = shift; + if ( defined wantarray and not @_ ) { + return $self->{values}->{$key}; + } + $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); + return $self; + }; +} + +foreach my $key ( @scalar_keys ) { + *$key = sub { + my $self = shift; + return $self->{values}->{$key} if defined wantarray and !@_; + $self->{values}->{$key} = shift; + return $self; + }; +} + +foreach my $key ( @array_keys ) { + *$key = sub { + my $self = shift; + return $self->{values}->{$key} if defined wantarray and !@_; + $self->{values}->{$key} ||= []; + push @{$self->{values}->{$key}}, @_; + return $self; + }; +} + +foreach my $key ( @resource_keys ) { + *$key = sub { + my $self = shift; + unless ( @_ ) { + return () unless $self->{values}->{resources}; + return map { $_->[1] } + grep { $_->[0] eq $key } + @{ $self->{values}->{resources} }; + } + return $self->{values}->{resources}->{$key} unless @_; + my $uri = shift or die( + "Did not provide a value to $key()" + ); + $self->resources( $key => $uri ); + return 1; + }; +} + +foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { + *$key = sub { + my $self = shift; + return $self->{values}->{$key} unless @_; + my @added; + while ( @_ ) { + my $module = shift or last; + my $version = shift || 0; + push @added, [ $module, $version ]; + } + push @{ $self->{values}->{$key} }, @added; + return map {@$_} @added; + }; +} + +# Resource handling +my %lc_resource = map { $_ => 1 } qw{ + homepage + license + bugtracker + repository +}; + +sub resources { + my $self = shift; + while ( @_ ) { + my $name = shift or last; + my $value = shift or next; + if ( $name eq lc $name and ! $lc_resource{$name} ) { + die("Unsupported reserved lowercase resource '$name'"); + } + $self->{values}->{resources} ||= []; + push @{ $self->{values}->{resources} }, [ $name, $value ]; + } + $self->{values}->{resources}; +} + +# Aliases for build_requires that will have alternative +# meanings in some future version of META.yml. +sub test_requires { shift->build_requires(@_) } +sub install_requires { shift->build_requires(@_) } + +# Aliases for installdirs options +sub install_as_core { $_[0]->installdirs('perl') } +sub install_as_cpan { $_[0]->installdirs('site') } +sub install_as_site { $_[0]->installdirs('site') } +sub install_as_vendor { $_[0]->installdirs('vendor') } + +sub dynamic_config { + my $self = shift; + unless ( @_ ) { + warn "You MUST provide an explicit true/false value to dynamic_config\n"; + return $self; + } + $self->{values}->{dynamic_config} = $_[0] ? 1 : 0; + return 1; +} + +sub perl_version { + my $self = shift; + return $self->{values}->{perl_version} unless @_; + my $version = shift or die( + "Did not provide a value to perl_version()" + ); + + # Normalize the version + $version = $self->_perl_version($version); + + # We don't support the reall old versions + unless ( $version >= 5.005 ) { + die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; + } + + $self->{values}->{perl_version} = $version; +} + +#Stolen from M::B +my %license_urls = ( + perl => 'http://dev.perl.org/licenses/', + apache => 'http://apache.org/licenses/LICENSE-2.0', + artistic => 'http://opensource.org/licenses/artistic-license.php', + artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', + lgpl => 'http://opensource.org/licenses/lgpl-license.php', + lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', + lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', + bsd => 'http://opensource.org/licenses/bsd-license.php', + gpl => 'http://opensource.org/licenses/gpl-license.php', + gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', + gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', + mit => 'http://opensource.org/licenses/mit-license.php', + mozilla => 'http://opensource.org/licenses/mozilla1.1.php', + open_source => undef, + unrestricted => undef, + restrictive => undef, + unknown => undef, +); + +sub license { + my $self = shift; + return $self->{values}->{license} unless @_; + my $license = shift or die( + 'Did not provide a value to license()' + ); + $self->{values}->{license} = $license; + + # Automatically fill in license URLs + if ( $license_urls{$license} ) { + $self->resources( license => $license_urls{$license} ); + } + + return 1; +} + +sub all_from { + my ( $self, $file ) = @_; + + unless ( defined($file) ) { + my $name = $self->name or die( + "all_from called with no args without setting name() first" + ); + $file = join('/', 'lib', split(/-/, $name)) . '.pm'; + $file =~ s{.*/}{} unless -e $file; + unless ( -e $file ) { + die("all_from cannot find $file from $name"); + } + } + unless ( -f $file ) { + die("The path '$file' does not exist, or is not a file"); + } + + $self->{values}{all_from} = $file; + + # Some methods pull from POD instead of code. + # If there is a matching .pod, use that instead + my $pod = $file; + $pod =~ s/\.pm$/.pod/i; + $pod = $file unless -e $pod; + + # Pull the different values + $self->name_from($file) unless $self->name; + $self->version_from($file) unless $self->version; + $self->perl_version_from($file) unless $self->perl_version; + $self->author_from($pod) unless $self->author; + $self->license_from($pod) unless $self->license; + $self->abstract_from($pod) unless $self->abstract; + + return 1; +} + +sub provides { + my $self = shift; + my $provides = ( $self->{values}->{provides} ||= {} ); + %$provides = (%$provides, @_) if @_; + return $provides; +} + +sub auto_provides { + my $self = shift; + return $self unless $self->is_admin; + unless (-e 'MANIFEST') { + warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; + return $self; + } + # Avoid spurious warnings as we are not checking manifest here. + local $SIG{__WARN__} = sub {1}; + require ExtUtils::Manifest; + local *ExtUtils::Manifest::manicheck = sub { return }; + + require Module::Build; + my $build = Module::Build->new( + dist_name => $self->name, + dist_version => $self->version, + license => $self->license, + ); + $self->provides( %{ $build->find_dist_packages || {} } ); +} + +sub feature { + my $self = shift; + my $name = shift; + my $features = ( $self->{values}->{features} ||= [] ); + my $mods; + + if ( @_ == 1 and ref( $_[0] ) ) { + # The user used ->feature like ->features by passing in the second + # argument as a reference. Accomodate for that. + $mods = $_[0]; + } else { + $mods = \@_; + } + + my $count = 0; + push @$features, ( + $name => [ + map { + ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ + } @$mods + ] + ); + + return @$features; +} + +sub features { + my $self = shift; + while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { + $self->feature( $name, @$mods ); + } + return $self->{values}->{features} + ? @{ $self->{values}->{features} } + : (); +} + +sub no_index { + my $self = shift; + my $type = shift; + push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; + return $self->{values}->{no_index}; +} + +sub read { + my $self = shift; + $self->include_deps( 'YAML::Tiny', 0 ); + + require YAML::Tiny; + my $data = YAML::Tiny::LoadFile('META.yml'); + + # Call methods explicitly in case user has already set some values. + while ( my ( $key, $value ) = each %$data ) { + next unless $self->can($key); + if ( ref $value eq 'HASH' ) { + while ( my ( $module, $version ) = each %$value ) { + $self->can($key)->($self, $module => $version ); + } + } else { + $self->can($key)->($self, $value); + } + } + return $self; +} + +sub write { + my $self = shift; + return $self unless $self->is_admin; + $self->admin->write_meta; + return $self; +} + +sub version_from { + require ExtUtils::MM_Unix; + my ( $self, $file ) = @_; + $self->version( ExtUtils::MM_Unix->parse_version($file) ); +} + +sub abstract_from { + require ExtUtils::MM_Unix; + my ( $self, $file ) = @_; + $self->abstract( + bless( + { DISTNAME => $self->name }, + 'ExtUtils::MM_Unix' + )->parse_abstract($file) + ); +} + +# Add both distribution and module name +sub name_from { + my ($self, $file) = @_; + if ( + Module::Install::_read($file) =~ m/ + ^ \s* + package \s* + ([\w:]+) + \s* ; + /ixms + ) { + my ($name, $module_name) = ($1, $1); + $name =~ s{::}{-}g; + $self->name($name); + unless ( $self->module_name ) { + $self->module_name($module_name); + } + } else { + die("Cannot determine name from $file\n"); + } +} + +sub _extract_perl_version { + if ( + $_[0] =~ m/ + ^\s* + (?:use|require) \s* + v? + ([\d_\.]+) + \s* ; + /ixms + ) { + my $perl_version = $1; + $perl_version =~ s{_}{}g; + return $perl_version; + } else { + return; + } +} + +sub perl_version_from { + my $self = shift; + my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); + if ($perl_version) { + $self->perl_version($perl_version); + } else { + warn "Cannot determine perl version info from $_[0]\n"; + return; + } +} + +sub author_from { + my $self = shift; + my $content = Module::Install::_read($_[0]); + if ($content =~ m/ + =head \d \s+ (?:authors?)\b \s* + ([^\n]*) + | + =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* + .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* + ([^\n]*) + /ixms) { + my $author = $1 || $2; + $author =~ s{E}{<}g; + $author =~ s{E}{>}g; + $self->author($author); + } else { + warn "Cannot determine author info from $_[0]\n"; + } +} + +sub _extract_license { + if ( + $_[0] =~ m/ + ( + =head \d \s+ + (?:licen[cs]e|licensing|copyrights?|legal)\b + .*? + ) + (=head\\d.*|=cut.*|) + \z + /ixms ) { + my $license_text = $1; + my @phrases = ( + 'under the same (?:terms|license) as (?:perl|the perl programming language)' => 'perl', 1, + 'under the terms of (?:perl|the perl programming language) itself' => 'perl', 1, + 'Artistic and GPL' => 'perl', 1, + 'GNU general public license' => 'gpl', 1, + 'GNU public license' => 'gpl', 1, + 'GNU lesser general public license' => 'lgpl', 1, + 'GNU lesser public license' => 'lgpl', 1, + 'GNU library general public license' => 'lgpl', 1, + 'GNU library public license' => 'lgpl', 1, + 'BSD license' => 'bsd', 1, + 'Artistic license' => 'artistic', 1, + 'GPL' => 'gpl', 1, + 'LGPL' => 'lgpl', 1, + 'BSD' => 'bsd', 1, + 'Artistic' => 'artistic', 1, + 'MIT' => 'mit', 1, + 'proprietary' => 'proprietary', 0, + ); + while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { + $pattern =~ s#\s+#\\s+#gs; + if ( $license_text =~ /\b$pattern\b/i ) { + return $license; + } + } + } else { + return; + } +} + +sub license_from { + my $self = shift; + if (my $license=_extract_license(Module::Install::_read($_[0]))) { + $self->license($license); + } else { + warn "Cannot determine license info from $_[0]\n"; + return 'unknown'; + } +} + +sub _extract_bugtracker { + my @links = $_[0] =~ m#L<( + \Qhttp://rt.cpan.org/\E[^>]+| + \Qhttp://github.com/\E[\w_]+/[\w_]+/issues| + \Qhttp://code.google.com/p/\E[\w_\-]+/issues/list + )>#gx; + my %links; + @links{@links}=(); + @links=keys %links; + return @links; +} + +sub bugtracker_from { + my $self = shift; + my $content = Module::Install::_read($_[0]); + my @links = _extract_bugtracker($content); + unless ( @links ) { + warn "Cannot determine bugtracker info from $_[0]\n"; + return 0; + } + if ( @links > 1 ) { + warn "Found more than one bugtracker link in $_[0]\n"; + return 0; + } + + # Set the bugtracker + bugtracker( $links[0] ); + return 1; +} + +sub requires_from { + my $self = shift; + my $content = Module::Install::_readperl($_[0]); + my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; + while ( @requires ) { + my $module = shift @requires; + my $version = shift @requires; + $self->requires( $module => $version ); + } +} + +sub test_requires_from { + my $self = shift; + my $content = Module::Install::_readperl($_[0]); + my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; + while ( @requires ) { + my $module = shift @requires; + my $version = shift @requires; + $self->test_requires( $module => $version ); + } +} + +# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to +# numbers (eg, 5.006001 or 5.008009). +# Also, convert double-part versions (eg, 5.8) +sub _perl_version { + my $v = $_[-1]; + $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; + $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; + $v =~ s/(\.\d\d\d)000$/$1/; + $v =~ s/_.+$//; + if ( ref($v) ) { + # Numify + $v = $v + 0; + } + return $v; +} + + + + + +###################################################################### +# MYMETA Support + +sub WriteMyMeta { + die "WriteMyMeta has been deprecated"; +} + +sub write_mymeta_yaml { + my $self = shift; + + # We need YAML::Tiny to write the MYMETA.yml file + unless ( eval { require YAML::Tiny; 1; } ) { + return 1; + } + + # Generate the data + my $meta = $self->_write_mymeta_data or return 1; + + # Save as the MYMETA.yml file + print "Writing MYMETA.yml\n"; + YAML::Tiny::DumpFile('MYMETA.yml', $meta); +} + +sub write_mymeta_json { + my $self = shift; + + # We need JSON to write the MYMETA.json file + unless ( eval { require JSON; 1; } ) { + return 1; + } + + # Generate the data + my $meta = $self->_write_mymeta_data or return 1; + + # Save as the MYMETA.yml file + print "Writing MYMETA.json\n"; + Module::Install::_write( + 'MYMETA.json', + JSON->new->pretty(1)->canonical->encode($meta), + ); +} + +sub _write_mymeta_data { + my $self = shift; + + # If there's no existing META.yml there is nothing we can do + return undef unless -f 'META.yml'; + + # We need Parse::CPAN::Meta to load the file + unless ( eval { require Parse::CPAN::Meta; 1; } ) { + return undef; + } + + # Merge the perl version into the dependencies + my $val = $self->Meta->{values}; + my $perl = delete $val->{perl_version}; + if ( $perl ) { + $val->{requires} ||= []; + my $requires = $val->{requires}; + + # Canonize to three-dot version after Perl 5.6 + if ( $perl >= 5.006 ) { + $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e + } + unshift @$requires, [ perl => $perl ]; + } + + # Load the advisory META.yml file + my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); + my $meta = $yaml[0]; + + # Overwrite the non-configure dependency hashs + delete $meta->{requires}; + delete $meta->{build_requires}; + delete $meta->{recommends}; + if ( exists $val->{requires} ) { + $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; + } + if ( exists $val->{build_requires} ) { + $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; + } + + return $meta; +} + +1; diff --git a/inc/Module/Install/Scripts.pm b/inc/Module/Install/Scripts.pm new file mode 100644 index 0000000..67c1408 --- /dev/null +++ b/inc/Module/Install/Scripts.pm @@ -0,0 +1,29 @@ +#line 1 +package Module::Install::Scripts; + +use strict 'vars'; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +sub install_script { + my $self = shift; + my $args = $self->makemaker_args; + my $exe = $args->{EXE_FILES} ||= []; + foreach ( @_ ) { + if ( -f $_ ) { + push @$exe, $_; + } elsif ( -d 'script' and -f "script/$_" ) { + push @$exe, "script/$_"; + } else { + die("Cannot find script '$_'"); + } + } +} + +1; diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm new file mode 100644 index 0000000..30e8529 --- /dev/null +++ b/inc/Module/Install/Win32.pm @@ -0,0 +1,64 @@ +#line 1 +package Module::Install::Win32; + +use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93'; + @ISA = 'Module::Install::Base'; + $ISCORE = 1; +} + +# determine if the user needs nmake, and download it if needed +sub check_nmake { + my $self = shift; + $self->load('can_run'); + $self->load('get_file'); + + require Config; + return unless ( + $^O eq 'MSWin32' and + $Config::Config{make} and + $Config::Config{make} =~ /^nmake\b/i and + ! $self->can_run('nmake') + ); + + print "The required 'nmake' executable not found, fetching it...\n"; + + require File::Basename; + my $rv = $self->get_file( + url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', + ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', + local_dir => File::Basename::dirname($^X), + size => 51928, + run => 'Nmake15.exe /o > nul', + check_for => 'Nmake.exe', + remove => 1, + ); + + die <<'END_MESSAGE' unless $rv; + +------------------------------------------------------------------------------- + +Since you are using Microsoft Windows, you will need the 'nmake' utility +before installation. It's available at: + + http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe + or + ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe + +Please download the file manually, save it to a directory in %PATH% (e.g. +C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to +that directory, and run "Nmake15.exe" from there; that will create the +'nmake.exe' file needed by this module. + +You may then resume the installation process described in README. + +------------------------------------------------------------------------------- +END_MESSAGE + +} + +1; diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm new file mode 100644 index 0000000..557bf41 --- /dev/null +++ b/inc/Module/Install/WriteAll.pm @@ -0,0 +1,60 @@ +#line 1 +package Module::Install::WriteAll; + +use strict; +use Module::Install::Base (); + +use vars qw{$VERSION @ISA $ISCORE}; +BEGIN { + $VERSION = '0.93';; + @ISA = qw{Module::Install::Base}; + $ISCORE = 1; +} + +sub WriteAll { + my $self = shift; + my %args = ( + meta => 1, + sign => 0, + inline => 0, + check_nmake => 1, + @_, + ); + + $self->sign(1) if $args{sign}; + $self->admin->WriteAll(%args) if $self->is_admin; + + $self->check_nmake if $args{check_nmake}; + unless ( $self->makemaker_args->{PL_FILES} ) { + $self->makemaker_args( PL_FILES => {} ); + } + + # Until ExtUtils::MakeMaker support MYMETA.yml, make sure + # we clean it up properly ourself. + $self->realclean_files('MYMETA.yml'); + + if ( $args{inline} ) { + $self->Inline->write; + } else { + $self->Makefile->write; + } + + # The Makefile write process adds a couple of dependencies, + # so write the META.yml files after the Makefile. + if ( $args{meta} ) { + $self->Meta->write; + } + + # Experimental support for MYMETA + if ( $ENV{X_MYMETA} ) { + if ( $ENV{X_MYMETA} eq 'JSON' ) { + $self->Meta->write_mymeta_json; + } else { + $self->Meta->write_mymeta_yaml; + } + } + + return 1; +} + +1; diff --git a/lib/Pod/ProjectDocs.pm b/lib/Pod/ProjectDocs.pm new file mode 100644 index 0000000..80e5619 --- /dev/null +++ b/lib/Pod/ProjectDocs.pm @@ -0,0 +1,303 @@ +package Pod::ProjectDocs; +use strict; +use warnings; + +use base qw/Class::Accessor::Fast/; + +use File::Spec; +use JSON; +use Pod::ProjectDocs::DocManager; +use Pod::ProjectDocs::Config; +use Pod::ProjectDocs::Parser::PerlPod; +use Pod::ProjectDocs::Parser::JavaScriptPod; +use Pod::ProjectDocs::CSS; +use Pod::ProjectDocs::ArrowImage; +use Pod::ProjectDocs::IndexPage; + +__PACKAGE__->mk_accessors(qw/managers components config/); + +our $VERSION = '0.38'; + +sub new { + my $class = shift; + my $self = bless { }, $class; + $self->_init(@_); + return $self; +} + +sub _init { + my($self, %args) = @_; + + # set absolute path to 'outroot' + $args{outroot} ||= File::Spec->curdir; + $args{outroot} = File::Spec->rel2abs($args{outroot}, File::Spec->curdir) + unless File::Spec->file_name_is_absolute( $args{outroot} ); + + # set absolute path to 'libroot' + $args{libroot} ||= File::Spec->curdir; + $args{libroot} = [ $args{libroot} ] unless ref $args{libroot}; + $args{libroot} = [ map { + File::Spec->file_name_is_absolute($_) ? $_ + : File::Spec->rel2abs($_, File::Spec->curdir) + } @{ $args{libroot} } ]; + + # check mtime by default, but can be overridden + $args{forcegen} ||= 0; + + $args{except} ||= []; + $args{except} = [ $args{except} ] unless ref $args{except}; + + $self->config( Pod::ProjectDocs::Config->new(%args) ); + + $self->_setup_components(); + $self->_setup_managers(); +} + +sub _setup_components { + my $self = shift; + $self->components( {} ); + $self->components->{css} + = Pod::ProjectDocs::CSS->new( config => $self->config ); + $self->components->{arrow} + = Pod::ProjectDocs::ArrowImage->new( config => $self->config ); +} + +sub _setup_managers { + my $self = shift; + $self->reset_managers(); + $self->add_manager('Perl Manuals', 'pod', Pod::ProjectDocs::Parser::PerlPod->new); + $self->add_manager('Perl Modules', 'pm', Pod::ProjectDocs::Parser::PerlPod->new); + $self->add_manager('Trigger Scripts', ['cgi', 'pl'], Pod::ProjectDocs::Parser::PerlPod->new); + $self->add_manager('JavaScript Libraries', 'js', Pod::ProjectDocs::Parser::JavaScriptPod->new); +} + +sub reset_managers { + my $self = shift; + $self->managers( [] ); +} + +sub add_manager { + my($self, $desc, $suffix, $parser) = @_; + push @{ $self->managers }, + Pod::ProjectDocs::DocManager->new( + config => $self->config, + desc => $desc, + suffix => $suffix, + parser => $parser, + ); +} + +sub gen { + my $self = shift; + + foreach my $comp_key ( keys %{ $self->components } ) { + my $comp = $self->components->{$comp_key}; + $comp->publish(); + } + + my @perl_modules; + my @js_libraries; + foreach my $manager ( @{ $self->managers } ) { + next if $manager->desc !~ /(Perl Modules|JavaScript Libraries)/; + my $ite = $manager->doc_iterator(); + while ( my $doc = $ite->next ) { + my $name = $doc->name; + my $path = $doc->get_output_path; + if ($manager->desc eq 'Perl Modules') { + $name =~ s/\-/\:\:/g; + push @perl_modules, { name => $name, path => $path }; + } + elsif ($manager->desc eq 'JavaScript Libraries') { + $name =~ s/\-/\./g; + push @js_libraries, { name => $name, path => $path }; + } + } + } + + foreach my $manager ( @{ $self->managers } ) { + + $manager->parser->local_modules( { + perl => \@perl_modules, + javascript => \@js_libraries, + } ); + + my $ite = $manager->doc_iterator(); + while ( my $doc = $ite->next ) { + my $html = $manager->parser->gen_html( + doc => $doc, + desc => $manager->desc, + components => $self->components, + ); + if ( $self->config->forcegen || $doc->is_modified ) { + $doc->copy_src(); + $doc->publish($html); + } + } + } + + my $index_page = Pod::ProjectDocs::IndexPage->new( + config => $self->config, + components => $self->components, + json => $self->get_managers_json, + ); + $index_page->publish(); +} + +sub get_managers_json { + my $self = shift; + my $js = JSON->new; + my $records = []; + foreach my $manager ( @{ $self->managers } ) { + my $record = { + desc => $manager->desc, + records => [], + }; + foreach my $doc ( @{ $manager->docs } ) { + push @{ $record->{records} }, { + path => $doc->relpath, + name => $doc->name, + title => $doc->title, + }; + } + if ( scalar( @{ $record->{records} } ) > 0 ) { + push @$records, $record; + } + } + return $js->encode($records); +} + +sub _croak { + my($self, $msg) = @_; + require Carp; + Carp::croak($msg); +} + +1; +__END__ + +=head1 NAME + +Pod::ProjectDocs - generates CPAN like pod pages + +=head1 SYNOPSIS + + #!/usr/bin/perl -w + use strict; + use Pod::ProjectDocs; + my $pd = Pod::ProjectDocs->new( + outroot => '/output/directory', + libroot => '/your/project/lib/root', + title => 'ProjectName', + ); + $pd->gen(); + + #or use pod2projdocs on your shell + pod2projdocs -out /output/directory -lib /your/project/lib/root + +=head1 DESCRIPTION + +This module allows you to generates CPAN like pod pages from your modules (not only perl but also javascript including pod) +for your projects. Set your library modules' root directory with libroot option. +And you have to set output directory's path with outroot option. +And this module searches your pm and pod files from your libroot, and generates +html files, and an index page lists up all your modules there. + +See the generated pages via HTTP with your browser. +Your documents of your modules are displayed like CPAN website. + +=head1 OPTIONS + +=over 4 + +=item outroot + +directory where you want to put the generated docs into. + +=item libroot + +your library's root directory + +You can set single path by string, or multiple by arrayref. + + my $pd = Pod::ProjectDocs->new( + outroot => '/path/to/output/directory', + libroot => '/path/to/lib' + ); + +or + + my $pd = Pod::ProjectDocs->new( + outroot => '/path/to/output/directory', + libroot => ['/path/to/lib1', '/path/to/lib2'], + ); + +=item title + +your project's name. + +=item desc + +description for your project. + +=item charset + +This is used in meta tag. default 'UTF-8' + +=item index + +whether you want to create index on each pod pages or not. +set 1 or 0. + +=item lang + +what language is set for xml:lang + +=item forcegen + +whether you want to generate HTML document even if source files are not updated. default is 0. + +=item except + +if you set this parameter as regex, the file matches this regex won't be checked. + + Pod::ProjectDocs->new( + except => qr/^specific_dir\//, + ...other parameters + ); + + Pod::ProjectDocs->new( + except => [qr/^specific_dir1\//, qr/^specific_dir2\//], + ...other parameters + ); + +=back + +=head1 pod2projdocs + +You need not to write script with this module, +I put the script named 'pod2projdocs' in this package. +At first, please execute follows. + + pod2projdocs -help + +or + + pod2projdocs -? + +=head1 SEE ALSO + +L + +=head1 AUTHOR + +Lyo Kato Elyo.kato@gmail.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright(C) 2005 by Lyo Kato + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.8.5 or, +at your option, any later version of Perl 5 you may have available. + +=cut diff --git a/lib/Pod/ProjectDocs/ArrowImage.pm b/lib/Pod/ProjectDocs/ArrowImage.pm new file mode 100644 index 0000000..a751186 --- /dev/null +++ b/lib/Pod/ProjectDocs/ArrowImage.pm @@ -0,0 +1,27 @@ +package Pod::ProjectDocs::ArrowImage; +use strict; +use warnings; +use base qw/Pod::ProjectDocs::File/; +use MIME::Base64; +use File::Basename; + +__PACKAGE__->default_name('up.gif'); +__PACKAGE__->data( do{ local $/; } ); +__PACKAGE__->is_bin(1); + +sub tag { + my($self, $doc) = @_; + my($name, $path) = fileparse $doc->get_output_path, qw/\.html/; + my $relpath = File::Spec->abs2rel($self->get_output_path, $path); + return sprintf qq|^|, $relpath; +} + +sub _get_data { + my $self = shift; + return decode_base64($self->data); +} + +1; +__DATA__ +R0lGODlhDwAPAIAAAABmmf///yH5BAEAAAEALAAAAAAPAA8AAAIjhI8Jwe1tXlgvulMpS1crT33W +uGBkpm3pZEEr1qGZHEuSKBYAOw== diff --git a/lib/Pod/ProjectDocs/CSS.pm b/lib/Pod/ProjectDocs/CSS.pm new file mode 100644 index 0000000..8353d79 --- /dev/null +++ b/lib/Pod/ProjectDocs/CSS.pm @@ -0,0 +1,616 @@ +package Pod::ProjectDocs::CSS; +use strict; +use warnings; +use base qw/Pod::ProjectDocs::File/; +use File::Basename; + +__PACKAGE__->default_name('podstyle.css'); +__PACKAGE__->data( do{ local $/; } ); + +sub tag { + my($self, $doc) = @_; + my($name, $path) = fileparse $doc->get_output_path, qw/\.html/; + my $relpath = File::Spec->abs2rel($self->get_output_path, $path); + return sprintf qq||, $relpath; +} + +1; +__DATA__ + +BODY, .logo { background: white; } + +BODY { + color: black; + font-family: arial,sans-serif; + margin: 0; + padding: 1ex; +} + +TABLE { + border-collapse: collapse; + border-spacing: 0; + border-width: 0; + color: inherit; +} + +IMG { border: 0; } +FORM { margin: 0; } +input { margin: 2px; } + +.logo { + float: left; + width: 264px; + height: 77px; +} + +.front .logo { + float: none; + display:block; +} + +.front .searchbox { + margin: 2ex auto; + text-align: center; +} + +.front .menubar { + text-align: center; +} + +.menubar { + background: #006699; + margin: 1ex 0; + padding: 1px; +} + +.menubar A { + padding: 0.8ex; + font: bold 10pt Arial,Helvetica,sans-serif; +} + +.menubar A:link, .menubar A:visited { + color: white; + text-decoration: none; +} + +.menubar A:hover { + color: #ff6600; + text-decoration: underline; +} + +A:link, A:visited { + background: transparent; + color: #006699; +} + +A[href="#POD_ERRORS"] { + background: transparent; + color: #FF0000; +} + +TD { + margin: 0; + padding: 0; +} + +DIV { + border-width: 0; +} + +DT { + margin-top: 1em; +} + +.credits TD { + padding: 0.5ex 2ex; +} + +.huge { + font-size: 32pt; +} + +.s { + background: #dddddd; + color: inherit; +} + +.s TD, .r TD { + padding: 0.2ex 1ex; + vertical-align: baseline; +} + +TH { + background: #bbbbbb; + color: inherit; + padding: 0.4ex 1ex; + text-align: left; +} + +TH A:link, TH A:visited { + background: transparent; + color: black; +} + +.box { + border: 1px solid #006699; + margin: 1ex 0; + padding: 0; +} + +.distfiles TD { + padding: 0 2ex 0 0; + vertical-align: baseline; +} + +.manifest TD { + padding: 0 1ex; + vertical-align: top; +} + +.l1 { + font-weight: bold; +} + +.l2 { + font-weight: normal; +} + +.t1, .t2, .t3, .t4 { + background: #006699; + color: white; +} +.t4 { + padding: 0.2ex 0.4ex; +} +.t1, .t2, .t3 { + padding: 0.5ex 1ex; +} + +/* IE does not support .box>.t1 Grrr */ +.box .t1, .box .t2, .box .t3 { + margin: 0; +} + +.t1 { + font-size: 1.4em; + font-weight: bold; + text-align: center; +} + +.t2 { + font-size: 1.0em; + font-weight: bold; + text-align: left; +} + +.t3 { + font-size: 1.0em; + font-weight: normal; + text-align: left; +} + +/* width: 100%; border: 0.1px solid #FFFFFF; */ /* NN4 hack */ + +.datecell { + text-align: center; + width: 17em; +} + +.cell { + padding: 0.2ex 1ex; + text-align: left; +} + +.label { + background: #aaaaaa; + color: black; + font-weight: bold; + padding: 0.2ex 1ex; + text-align: right; + white-space: nowrap; + vertical-align: baseline; +} + +.categories { + border-bottom: 3px double #006699; + margin-bottom: 1ex; + padding-bottom: 1ex; +} + +.categories TABLE { + margin: auto; +} + +.categories TD { + padding: 0.5ex 1ex; + vertical-align: baseline; +} + +.path A { + background: transparent; + color: #006699; + font-weight: bold; +} + +.pages { + background: #dddddd; + color: #006699; + padding: 0.2ex 0.4ex; +} + +.path { + background: #dddddd; + border-bottom: 1px solid #006699; + color: #006699; + /* font-size: 1.4em;*/ + margin: 1ex 0; + padding: 0.5ex 1ex; +} + +.menubar TD { + background: #006699; + color: white; +} + +.menubar { + background: #006699; + color: white; + margin: 1ex 0; + padding: 1px; +} + +.menubar .links { + background: transparent; + color: white; + padding: 0.2ex; + text-align: left; +} + +.menubar .searchbar { + background: black; + color: black; + margin: 0px; + padding: 2px; + text-align: right; +} + +A.m:link, A.m:visited { + background: #006699; + color: white; + font: bold 10pt Arial,Helvetica,sans-serif; + text-decoration: none; +} + +A.o:link, A.o:visited { + background: #006699; + color: #ccffcc; + font: bold 10pt Arial,Helvetica,sans-serif; + text-decoration: none; +} + +A.o:hover { + background: transparent; + color: #ff6600; + text-decoration: underline; +} + +A.m:hover { + background: transparent; + color: #ff6600; + text-decoration: underline; +} + +table.dlsip { + background: #dddddd; + border: 0.4ex solid #dddddd; +} + +.pod PRE { + background: #eeeeee; + border: 1px solid #888888; + color: black; + padding: 1em; + white-space: pre; +} + +.pod H1 { + background: transparent; + color: #006699; + font-size: large; +} + +.pod H2 { + background: transparent; + color: #006699; + font-size: medium; +} + +.pod IMG { + vertical-align: top; +} + +.pod .toc A { + text-decoration: none; +} + +.pod .toc LI { + line-height: 1.2em; + list-style-type: none; +} + +.faq DT { + font-size: 1.4em; + font-weight: bold; +} + +.chmenu { + background: black; + color: red; + font: bold 1.1em Arial,Helvetica,sans-serif; + margin: 1ex auto; + padding: 0.5ex; +} + +.chmenu TD { + padding: 0.2ex 1ex; +} + +.chmenu A:link, .chmenu A:visited { + background: transparent; + color: white; + text-decoration: none; +} + +.chmenu A:hover { + background: transparent; + color: #ff6600; + text-decoration: underline; +} + +.column { + padding: 0.5ex 1ex; + vertical-align: top; +} + +.datebar { + margin: auto; + width: 14em; +} + +.date { + background: transparent; + color: #008000; +} + +.footer { + margin-top: 1ex; + text-align: right; + color: #006699; + font-size: x-small; + border-top: 1px solid #006699; + line-height: 120%; +} + +.front .footer { + border-top: none; +} + +.search_highlight { + color: #ff6600; +} + +.def_HorzCross { + color: #000000; + background-color: #313b30; +} + +.def_VertCross { + color: #000000; + background-color: #313b30; +} + +.def_Number { + color: #00a800; +} + +.def_NumberDec { + color: #008c00; +} + +.def_NumHex { + color: #008000; +} + +.def_NumberBin { + color: #007d00; +} + +.def_NumberOct { + color: #008c00; +} + +.def_NumberFloat { + color: #009f00; +} + +.def_NumberSuffix { + color: #006600; +} + +.def_String { + color: #00c4c4; +} + +.def_Special { + color: #008B8B; +} + +.def_StringContent { + color: #008080; +} + +.def_StringEdge { + color: #02d045; +} + +.def_CharacterContent { + color: #008080; +} + +.def_Comment { + color: #9999a9; +} + +.def_CommentContent { + color: #8695b8; + font-weight: bold; +} + +.def_CommentDoc { + color: #90b0e0; +} + +.def_SymbolStrong { + color: #b060b0; +} + +.def_Prefix { + color: #00dddd; +} + +.def_Operator { + color: #00dddd; +} + +.def_Keyword { + color: #A52A2A; + font-weight: bold; +} + +.def_KeywordStrong { + color: #904050; +} + +.def_ClassKeyword { + color: #bb7977; + font-weight: bold; +} + +.def_TypeKeyword { + color: #bb7977; +} + +.def_Register { + color: #d0d09f; +} + +.def_Constant { + color: #007d45; +} + +.def_BooleanConstant { + color: #0f4d75; +} + +.def_Var { + color: #007997; +} + +.def_VarStrong { + color: #007997; +} + +.def_Identifier { + color: #005fd2; +} + +.def_Directive { + color: #008073; +} + +.def_Param { + color: #64810c; +} + +.def_Tag { + color: #f6c1d0; +} + +.def_OpenTag { + color: #ff8906; +} + +.def_CloseTag { + color: #fb8400; +} + +.def_Label { + color: #e34adc; +} + +.def_LabelStrong { + color: #000000; + background-color: #a8a800; +} + +.def_Insertion { + color: #ffffff; + background-color: #281800; +} + +.def_InsertionStart { + color: #800000; + background-color: #ffffa4; +} + +.def_InsertionEnd { + color: #800000; + background-color: #ffffa4; +} + +.def_Error { + color: #ffffff; + background-color: #dd0000; +} + +.def_ErrorText { + color: #ee00ee; +} + +.def_TODO { + color: #ffffff; + background-color: #3c215f; +} + +.def_Debug { + color: #011a47; + background-color: #007084; +} + +.def_Path { + color: #40015a; +} + +.def_URL { + color: #6070ec; +} + +.def_EMail { + color: #a160f4; +} + +.def_Date { + color: #009797; +} + +.def_Time { + color: #8745a0; +} + +.def_PairStart { + color: #aa4444; +} + +.def_PairEnd { + color: #aa4444; +} diff --git a/lib/Pod/ProjectDocs/Config.pm b/lib/Pod/ProjectDocs/Config.pm new file mode 100644 index 0000000..b9b8ebd --- /dev/null +++ b/lib/Pod/ProjectDocs/Config.pm @@ -0,0 +1,50 @@ +package Pod::ProjectDocs::Config; +use strict; +use warnings; + +use base qw/Class::Accessor::Fast/; + +use Readonly; + +__PACKAGE__->mk_accessors(qw/ + title + desc + charset + verbose + index + outroot + libroot + forcegen + lang + except +/); + +Readonly my $DEFAULT_TITLE => qq/MyProject's Libraries/; +Readonly my $DEFAULT_DESC => qq/manuals and libraries/; +Readonly my $DEFAULT_CHARSET => qq/UTF-8/; +Readonly my $DEFAULT_LANG => qq/en/; + +sub new { + my $class = shift; + my $self = bless { }, $class; + $self->_init(@_); + return $self; +} + +sub _init { + my($self, %args) = @_; + $self->title ( $args{title} || $DEFAULT_TITLE ); + $self->desc ( $args{desc} || $DEFAULT_DESC ); + $self->charset ( $args{charset} || $DEFAULT_CHARSET ); + $self->lang ( $args{lang} || $DEFAULT_LANG ); + $self->verbose ( $args{verbose} ); + $self->index ( $args{index} ); + $self->outroot ( $args{outroot} ); + $self->libroot ( $args{libroot} ); + $self->forcegen( $args{forcegen} ); + $self->except ( $args{except} ); +} + +1; +__END__ + diff --git a/lib/Pod/ProjectDocs/Doc.pm b/lib/Pod/ProjectDocs/Doc.pm new file mode 100644 index 0000000..6016a8f --- /dev/null +++ b/lib/Pod/ProjectDocs/Doc.pm @@ -0,0 +1,97 @@ +package Pod::ProjectDocs::Doc; +use strict; +use warnings; +use base qw/Pod::ProjectDocs::File/; +use File::Basename; +use File::Spec; +use File::Copy; + +__PACKAGE__->mk_accessors(qw/origin suffix origin_root title/); +__PACKAGE__->data( do{ local $/; } ); + +sub _init { + my($self, %args) = @_; + $self->SUPER::_init(%args); + $self->origin( $args{origin} ); + $self->origin_root( $args{origin_root} ); + $self->suffix( $args{suffix} ); + $self->_set_relpath; +} + +sub _set_relpath { + my $self = shift; + my $suffix = $self->suffix; + my($name, $dir) = fileparse $self->origin, qr/\.$suffix/; + my $reldir = File::Spec->abs2rel($dir, $self->origin_root); + $reldir ||= File::Spec->curdir; + my $outroot = $self->config->outroot; + $self->_check_dir($reldir, $outroot); + $self->_check_dir($reldir, File::Spec->catdir($outroot, "src")); + my $relpath = File::Spec->catdir($reldir, $name); + $self->name( join "-", File::Spec->splitdir($relpath) ); + $self->relpath($relpath.".".$suffix.".html"); +} + +sub _check_dir { + my($self, $dir, $path) = @_; + $self->_mkdir($path); + my @dirs = File::Spec->splitdir($dir); + foreach my $dir (@dirs) { + $path = File::Spec->catdir($path, $dir); + $self->_mkdir($path); + } +} + +sub _mkdir { + my($self, $path) = @_; + unless(-e $path && -d _) { + mkdir($path, 0755) + or $self->_croak(qq/Can't make directory [$path]./); + } +} + +sub get_output_src_path { + my $self = shift; + my $outroot = File::Spec->catdir($self->config->outroot, "src"); + my $relpath = $self->relpath; + my $suffix = $self->suffix; + $relpath =~ s/\.html$//; + my $path = File::Spec->catfile($outroot, $relpath); + return $path; +} + +sub copy_src { + my $self = shift; + my $origin = $self->origin; + my $newsrc = $self->get_output_src_path; + File::Copy::copy($origin, $newsrc); +} + +sub is_modified { + my $self = shift; + my $origin = $self->origin; + my $newsrc = $self->get_output_src_path; + return 1 unless( -e $newsrc ); + return (-M $origin < -M $newsrc) ? 1 : 0; +} + +1; +__DATA__ +
+

[% title | html %]

+ + + + + +
Description[% desc | html | html_line_break %]
+
+
+ [% title | html %] > [% mgr_desc | html %] > + [% name | html %] +
+
+Source +
+ + diff --git a/lib/Pod/ProjectDocs/DocManager.pm b/lib/Pod/ProjectDocs/DocManager.pm new file mode 100644 index 0000000..ecb81af --- /dev/null +++ b/lib/Pod/ProjectDocs/DocManager.pm @@ -0,0 +1,142 @@ +package Pod::ProjectDocs::DocManager; +use strict; +use warnings; +use base qw/Class::Accessor::Fast/; + +use File::Find; +use Pod::ProjectDocs::Doc; + +__PACKAGE__->mk_accessors(qw/ + config + desc + suffix + parser + docs +/); + +sub new { + my $class = shift; + my $self = bless {}, $class; + $self->_init(@_); + return $self; +} + +sub _init { + my ( $self, %args ) = @_; + $args{suffix} = [ $args{suffix} ] unless ref $args{suffix}; + $self->config( $args{config} ); + $self->desc( $args{desc} ); + $self->suffix( $args{suffix} ); + $self->parser( $args{parser} ); + $self->docs( [] ); + $self->_find_files; +} + +sub _find_files { + my $self = shift; + foreach my $dir ( @{ $self->config->libroot } ) { + unless ( -e $dir && -d _ ) { + $self->_croak(qq/$dir isn't detected or it's not a directory./); + } + } + my $suffixs = $self->suffix; + foreach my $dir ( @{ $self->config->libroot } ) { + foreach my $suffix (@$suffixs) { + my $wanted = sub { + return unless $File::Find::name =~ /\.$suffix$/; + ( my $path = $File::Find::name ) =~ s#^\\.##; + my ( $fname, $fdir ) = + File::Basename::fileparse( $path, qr/\.$suffix/ ); + my $reldir = File::Spec->abs2rel( $fdir, $dir ); + $reldir ||= File::Spec->curdir; + my $relpath = File::Spec->catdir( $reldir, $fname ); + $relpath .= "."; + $relpath .= $suffix; + my $matched = 0; + + foreach my $regex ( @{ $self->config->except } ) { + if ( $relpath =~ /$regex/ ) { + $matched = 1; + last; + } + } + unless ($matched) { + push @{ $self->docs }, + Pod::ProjectDocs::Doc->new( + config => $self->config, + origin => $path, + origin_root => $dir, + suffix => $suffix, + ); + } + }; + File::Find::find( { no_chdir => 1, wanted => $wanted }, $dir ); + } + } + $self->docs( [ sort { $a->name cmp $b->name } @{ $self->docs } ] ); +} + +sub get_doc_names { + my $self = shift; + my @names = map { $_->name } @{ $self->docs }; + return wantarray ? @names : \@names; +} + +sub get_docs_num { + my $self = shift; + return scalar @{ $self->docs }; +} + +sub get_doc_at { + my ( $self, $index ) = @_; + return $self->docs->[$index]; +} + +sub doc_iterator { + my $self = shift; + return Pod::ProjectDocs::DocManager::Iterator->new($self); +} + +sub _croak { + my ( $self, $msg ) = @_; + require Carp; + Carp::croak($msg); +} + +package Pod::ProjectDocs::DocManager::Iterator; +use base qw/Class::Accessor::Fast/; +__PACKAGE__->mk_accessors(qw/manager index/); + +sub new { + my $class = shift; + my $self = bless {}, $class; + $self->_init(@_); + return $self; +} + +sub _init { + my ( $self, $manager ) = @_; + $self->index(0); + $self->manager($manager); +} + +sub next { + my $self = shift; + if ( $self->manager->get_docs_num > $self->index ) { + my $doc = $self->manager->get_doc_at( $self->index ); + $self->index( $self->index + 1 ); + return $doc; + } + else { + return undef; + } +} + +sub reset { + my $self = shift; + $self->index(0); +} + +1; +__END__ + diff --git a/lib/Pod/ProjectDocs/File.pm b/lib/Pod/ProjectDocs/File.pm new file mode 100644 index 0000000..c83ca06 --- /dev/null +++ b/lib/Pod/ProjectDocs/File.pm @@ -0,0 +1,57 @@ +package Pod::ProjectDocs::File; +use strict; +use warnings; +use base qw/Class::Accessor::Fast Class::Data::Inheritable/; + +use IO::File; + +__PACKAGE__->mk_classdata($_) for qw/data default_name is_bin/; +__PACKAGE__->mk_accessors(qw/config name relpath/); +__PACKAGE__->is_bin(0); + +sub new { + my $class = shift; + my $self = bless { }, $class; + $self->_init(@_); + return $self; +} + +sub _init { + my($self, %args) = @_; + $self->config( $args{config} ); +} + +sub _get_data { + my $self = shift; + return $self->data; +} + +sub publish { + my($self, $data) = @_; + $data ||= $self->_get_data(); + my $path = $self->get_output_path; + my $fh = IO::File->new($path, "a") + or $self->_croak(qq/Can't open $path./); + $fh->seek(0, 0); + $fh->truncate(0); + $fh->print($data); + $fh->close; +} + +sub get_output_path { + my $self = shift; + my $outroot = $self->config->outroot; + my $relpath = $self->relpath || $self->default_name; + my $path = File::Spec->catfile($outroot, $relpath); + return $path; +} + +sub _croak { + my($self, $msg) = @_; + require Carp; + Carp::croak($msg); +} + +1; +__END__ + diff --git a/lib/Pod/ProjectDocs/IndexPage.pm b/lib/Pod/ProjectDocs/IndexPage.pm new file mode 100644 index 0000000..eabf1cb --- /dev/null +++ b/lib/Pod/ProjectDocs/IndexPage.pm @@ -0,0 +1,141 @@ +package Pod::ProjectDocs::IndexPage; +use strict; +use warnings; +use base qw/Pod::ProjectDocs::File/; +use Pod::ProjectDocs::Template; + +__PACKAGE__->default_name('index.html'); +__PACKAGE__->data( do{ local $/; } ); + +__PACKAGE__->mk_accessors(qw/json components/); + +sub _init { + my($self, %args) = @_; + $self->SUPER::_init(%args); + $self->json( $args{json} ); + $self->components( $args{components} ); +} + +sub _get_data { + my $self = shift; + my $params = { + title => $self->config->title, + desc => $self->config->desc, + lang => $self->config->lang, + json => $self->json, + css => $self->components->{css}->tag($self), + charset => $self->config->charset || 'UTF-8', + }; + my $tt = Pod::ProjectDocs::Template->new; + my $text = $tt->process($self, $self->data, $params); + return $text; +} + +1; +__DATA__ + + + + + +[% title | html %] +[% css %] + + + +
+

[% title | html %]

+ + + + + +
Description[% desc | html_line_break %]
+
+ +
+

Search

+ + + + +
+
+ +
+
+ +[% FOREACH manager IN managers %] +[% IF manager.docs.size %] +
+

[% manager.desc | html %]

+ + [% seq = 1 %] + [% FOREACH doc IN manager.docs %] + + + + + [% seq = seq + 1 %] + [% END %] +
+ [% doc.name | html %] + + [% doc.title | html %] +
+
+[% END %] +[% END %] + + + diff --git a/lib/Pod/ProjectDocs/Parser.pm b/lib/Pod/ProjectDocs/Parser.pm new file mode 100644 index 0000000..d860566 --- /dev/null +++ b/lib/Pod/ProjectDocs/Parser.pm @@ -0,0 +1,735 @@ +package Pod::ProjectDocs::Parser; +use strict; +use warnings; +use base qw/Pod::Parser Class::Accessor::Fast Class::Data::Inheritable/; +use Pod::ParseUtils; +use URI::Escape; +use File::Spec; +use File::Basename; +use Pod::ProjectDocs::Template; + + +our $METHOD_REGEXP ||= qr/^(\w+).*/; + +BEGIN { + our $HIGHLIGHTER; + eval { + require Syntax::Highlight::Universal; + $HIGHLIGHTER = Syntax::Highlight::Universal->new; + }; + *highlighten = $HIGHLIGHTER ? sub { + my ($self, $type, $str) = @_; + $HIGHLIGHTER->highlight($type, $str); + } : sub { return $_[2] }; +} + +# most of code is borrowed from Pod::Xhtml +__PACKAGE__->mk_accessors(qw/components local_modules current_files_output_path/); +__PACKAGE__->mk_classdata($_) for qw/COMMANDS SEQ language/; + +__PACKAGE__->COMMANDS( { + map { $_ => 1 } qw/pod head1 head2 head3 head4 item over back for begin end/ +} ); + +__PACKAGE__->SEQ( { + B => \&seqB, + C => \&seqC, + E => \&seqE, + F => \&seqF, + I => \&seqI, + L => \&seqL, + S => \&seqS, + X => \&seqX, + Z => \&seqZ, +} ); + +########## New PUBLIC methods for this class +sub asString { my $self = shift; return $self->{buffer}; } +sub asStringRef { my $self = shift; return \$self->{buffer}; } +sub addHeadText { my $self = shift; $self->{HeadText} .= shift; } +sub addBodyOpenText { my $self = shift; $self->{BodyOpenText} .= shift; } +sub addBodyCloseText { my $self = shift; $self->{BodyCloseText} .= shift; } + +########## Override methods in Pod::Parser +########## PUBLIC INTERFACE +sub parse_from_file { + my $self = shift; + $self->resetMe; + $self->SUPER::parse_from_file(@_); +} + +sub parse_from_filehandle { + my $self = shift; + $self->resetMe; + $self->SUPER::parse_from_filehandle(@_); +} + +########## INTERNALS +sub initialize { + my $self = shift; + + $self->{TopLinks} = qq(

Top

) unless defined $self->{TopLinks}; + $self->{MakeIndex} = 1 unless defined $self->{MakeIndex}; + $self->{MakeMeta} = 1 unless defined $self->{MakeMeta}; + $self->{FragmentOnly} = 0 unless defined $self->{FragmentOnly}; + $self->{HeadText} = $self->{BodyOpenText} = $self->{BodyCloseText} = ''; + $self->{LinkParser} ||= new Pod::Hyperlink; + $self->{IsFirstCommand} = 1; + $self->{FirstAnchor} = "TOP"; + $self->SUPER::initialize(); +} + +sub command { + my ($parser, $command, $paragraph, $line_num, $pod_para) = @_; + my $ptree = $parser->parse_text( $paragraph, $line_num ); + $pod_para->parse_tree( $ptree ); + $parser->parse_tree->append( $pod_para ); +} + +sub verbatim { + my ($parser, $paragraph, $line_num, $pod_para) = @_; + $parser->parse_tree->append( $pod_para ); +} + +sub textblock { + my ($parser, $paragraph, $line_num, $pod_para) = @_; + my $ptree = $parser->parse_text( $paragraph, $line_num ); + $pod_para->parse_tree( $ptree ); + $parser->parse_tree->append( $pod_para ); +} + +sub end_pod { + my $self = shift; + my $ptree = $self->parse_tree; + + # clean up tree ready for parse + foreach my $para (@$ptree) { + if ($para->{'-prefix'} eq '=') { + $para->{'TYPE'} = 'COMMAND'; + } elsif (! @{$para->{'-ptree'}}) { + $para->{'-ptree'}->[0] = $para->{'-text'}; + $para->{'TYPE'} = 'VERBATIM'; + } else { + $para->{'TYPE'} = 'TEXT'; + } + foreach (@{$para->{'-ptree'}}) { + unless (ref $_) { s/\n\s+$//; } + } + } + + # now loop over each para and expand any html escapes or sequences + $self->_paraExpand( $_ ) foreach (@$ptree); + + $self->{buffer} =~ s/(\n?)<\/pre>\s*
/$1/sg; # concatenate 'pre' blocks
+    1 while $self->{buffer} =~ s/
(\s+)<\/pre>/$1/sg;
+    $self->{buffer} = $self->_makeIndex . $self->{buffer} if $self->{MakeIndex};
+    $self->{buffer} =~ s/<<>>/$self->{FirstAnchor}/ge;
+    $self->{buffer} = join "\n", qq[
], $self->{buffer}, "
"; + + # Expand internal L<> links to the correct sections + $self->{buffer} =~ s/#<<<(.*?)>>>/'#' . $self->_findSection($1)/eg; + die "gotcha" if $self->{buffer} =~ /#<<%s\n", + qq(), + qq(\n), + _htmlEscape( $self->{doctitle} ); + $headblock .= $self->_makeMeta if $self->{MakeMeta}; + + unless ($self->{FragmentOnly}) { + $self->{buffer} = $headblock . $self->{HeadText} . "\n\n" . $self->{BodyOpenText} . $self->{buffer}; + $self->{buffer} .= $self->{BodyCloseText} . "\n\n"; + } + + # in stringmode we only accumulate the XHTML else we print it to the + # filehandle + unless ($self->{StringMode}) { + my $out_fh = $self->output_handle; + print $out_fh $self->{buffer}; + } +} + +########## Everything else is PRIVATE +sub resetMe { + my $self = shift; + $self->{'-ptree'} = new Pod::ParseTree; + $self->{'sections'} = []; + $self->{'listKind'} = []; + $self->{'listHasItems'} = []; + $self->{'dataSections'} = []; + $self->{'section_names'} = {}; + $self->{'section_ids'} = {}; + + foreach (qw(inList titleflag )) { $self->{$_} = 0; } + foreach (qw(buffer doctitle)) { $self->{$_} = ''; } +} + +sub parse_tree { return $_[0]->{'-ptree'}; } + +sub _paraExpand { + my $self = shift; + my $para = shift; + + # collapse interior sequences and strings + foreach ( @{$para->{'-ptree'}} ) { + $_ = (ref $_) ? $self->_handleSequence($_) : _htmlEscape( $_ ); + } + + # the parse tree has now been collapsed into a list of strings + if ($para->{TYPE} eq 'TEXT') { + return if @{$self->{dataSections}}; + $self->_addTextblock( join('', @{$para->{'-ptree'}}) ); + } elsif ($para->{TYPE} eq 'VERBATIM') { + return if @{$self->{dataSections}}; + my $paragraph = "
" . join('', @{$para->{'-ptree'}}) . "\n\n
"; + my $parent_list = $self->{listKind}[-1]; + if ($parent_list && $parent_list == 2) { + $paragraph = "
$paragraph
"; + } + $self->{buffer} .= $paragraph; + if ($self->{titleflag} != 0) { + $self->_setTitle( $paragraph ); + warn "NAME followed by verbatim paragraph"; + } + } elsif ($para->{TYPE} eq 'COMMAND') { + $self->_addCommand($para->{'-name'}, join('', @{$para->{'-ptree'}}), $para->{'-text'}, $para->{'-line'} ) + } else { + warn "Unrecognized paragraph type $para->{TYPE} found at $self->{_INFILE} line $para->{'-line'}\n"; + } +} + +sub _addCommand { + my $self = shift; + my ($command, $paragraph, $raw_para, $line) = @_; + my $anchor; + + unless (exists $self->COMMANDS->{$command}) { + warn "Unrecognized command '$command' skipped at $self->{_INFILE} line $line\n"; + return; + } + + for ($command) { + /^head1/ && do { + $anchor = $self->_addSection( 'head1', $paragraph ); + $self->{buffer} .= qq(

$paragraph ) + .($self->{TopLinks} ? $self->{TopLinks} : '').qq(

)."\n\n"; + if ($anchor eq 'NAME') { $self->{titleflag} = 1; } + last; + }; + /^head([234])/ && do { + my $head_level = $1; + $anchor = $self->_addSection( "head${head_level}", $paragraph ); + $self->{buffer} .= qq($paragraph\n\n); + (my $method = $paragraph) =~ s#$METHOD_REGEXP#$1#; + if ( exists $self->{_source_code}{$method} ) { + $self->{buffer} .= qq{

[Source]

+
+
\n\n};
+                $self->{buffer} .= $self->{_source_code}{$method};
+                $self->{buffer} .= qq{
\n\n}; + } + last; + }; + /^item/ && do { + unless ($self->{inList}) { + warn "Not in list at $self->{_INFILE} line $line\n"; + last; + } + + $self->{listHasItems}[-1] = 1; + $self->{listCurrentParas}[-1] = 0; + + # is this the first item in the list? + if (@{$self->{listKind}} && $self->{listKind}[-1] == 0) { + my $parent_list = $self->{listKind}[-2]; # this is a sub-list + if ($parent_list && $parent_list == 1) { + #
    sub lists must be in an
  • [BEGIN] + $self->{buffer} .= "
  • "; + } elsif ($parent_list && $parent_list == 2) { + #
    sub lists must be in a
    [BEGIN] + $self->{buffer} .= "
    "; + } + + if ($paragraph eq '*') { + $self->{listKind}[-1] = 1; + $self->{buffer} .= "
      \n"; + } else { + $self->{listKind}[-1] = 2; + $self->{buffer} .= "
      \n"; + } + } else { + # close last list item's tag# + if ($self->{listKind}[-1] == 1) { + $self->{buffer} .= "\n"; + } + } + if (@{$self->{listKind}} && $self->{listKind}[-1] == 2) { + $self->{buffer} .= qq(\t{MakeIndex} >= 2) { + $anchor = $self->_addSection( 'list', $paragraph ); + $self->{buffer} .= qq( id="$anchor"); + } + $self->{buffer} .= ">"; + $self->{buffer} .= qq($paragraph\n); + } + last; + }; + /^over/ && do { + $self->{inList}++; + push @{$self->{listKind}}, 0; + push @{$self->{listHasItems}}, 0; + push @{$self->{sections}}, 'OVER'; + push @{$self->{listCurrentParas}}, 0; + }; + /^back/ && do { + if (--$self->{inList} < 0) { + warn "=back commands don't balance =overs at $self->{_INFILE} line $line\n"; + last; + } elsif ($self->{listHasItems} == 0) { + warn "empty list at $self->{_INFILE} line $line\n"; + last; + } elsif (@{$self->{listKind}} && $self->{listKind}[-1] == 1) { + $self->{buffer} .= "\n
    \n\n"; + } else { + $self->{buffer} .= "
    \n"; + } + + my $parent_list = $self->{listKind}[-2]; # this is a sub-list + if ($parent_list && $parent_list == 1) { + #
      sub lists must be in an
    • [END] + $self->{buffer} .= "
    • \n"; + } + if ($parent_list && $parent_list == 2) { + #
      sub lists must be in a
      [END] + $self->{buffer} .= "
      \n"; + } + + if ($self->{sections}[-1] eq 'OVER') + { + pop @{$self->{sections}}; + } else { + push @{$self->{sections}}, 'BACK'; + } + pop @{$self->{listHasItems}}; + pop @{$self->{listKind}}; + pop @{$self->{listCurrentParas}}; + last; + }; + /^for/ && do { + my ($html) = $raw_para =~ /^\s*(?:pod2)?x?html\s+(.*)/; + $self->{buffer} .= $html if $html; + }; + /^begin/ && do { + my ($ident) = $paragraph =~ /(\S+)/; + push @{$self->{dataSections}}, $ident; + last; + }; + /^end/ && do { + my ($ident) = $paragraph =~ /(\S+)/; + unless (@{$self->{dataSections}}) { + warn "no corresponding '=begin $ident' marker at $self->{_INFILE} line $line\n"; + last; + } + my $current_section = $self->{dataSections}[-1]; + unless ($current_section eq $ident) { + warn "'=end $ident' doesn't match '=begin $current_section' at $self->{_INFILE} line $line\n"; + last; + } + pop @{$self->{dataSections}}; + last; + }; + } + if ($anchor && $self->{IsFirstCommand}) + { + $self->{FirstAnchor} = $anchor; + $self->{IsFirstCommand} = 0; + } +} + +sub _addTextblock { + my $self = shift; + my $paragraph = shift; + + if ($self->{titleflag} != 0) { $self->_setTitle( $paragraph ); } + + if (! @{$self->{listKind}} || $self->{listKind}[-1] == 0) { + $self->{buffer} .= "

      $paragraph

      \n\n"; + } elsif (@{$self->{listKind}} && $self->{listKind}[-1] == 1) { + if ($self->{listCurrentParas}[-1]++ == 0) { + $self->{buffer} .= "\t
    • $paragraph"; + } else { + $self->{buffer} .= "\n

      $paragraph"; + } + } else { + $self->{buffer} .= "\t\t

      $paragraph

      \n"; + } +} + +# expand interior sequences recursively, bottom up +sub _handleSequence { + my $self = shift; + my $seq = shift; + my $buffer = ''; + + foreach (@{$seq->{'-ptree'}}) { + if (ref $_) { + $buffer .= $self->_handleSequence($_); + } else { + $buffer .= _htmlEscape($_); + } + } + + unless (exists $self->SEQ->{$seq->{'-name'}}) { + warn "Unrecognized special sequence '$seq->{'-name'}' skipped at $self->{_INFILE} line $seq->{'-line'}\n"; + return $buffer; + } + return $self->SEQ->{$seq->{'-name'}}->($self, $buffer); +} + +sub _makeIndexId { + my $arg = shift; + + $arg =~ s/\W+/_/g; + $arg =~ s/^_+|_+$//g; + $arg =~ s/__+/_/g; + $arg = substr($arg, 0, 36); + return $arg; +} + +sub _addSection { + my $self = shift; + my ($type, $htmlarg) = @_; + return unless defined $htmlarg; + + my $index_id; + if ($self->{section_names}{$htmlarg}) { + $index_id = $self->{section_names}{$htmlarg}; + } else { + $index_id = _makeIndexId($htmlarg); + if ($self->{section_ids}{$index_id}) { + $index_id .= "-" . ++$self->{section_ids}{$index_id}; + } else { + $self->{section_ids}{$index_id}++; + } + $self->{section_names}{$htmlarg} = $index_id; + } + + push( @{$self->{sections}}, [$type, $index_id, $htmlarg]); + return $index_id; +} + +sub _findSection { + my $self = shift; + my ($htmlarg) = @_; + + my $index_id; + if ($index_id = $self->{section_names}{$htmlarg}) { + return $index_id; + } else { + return _makeIndexId($htmlarg); + } +} + +sub _get_elem_level { + my $elem = shift; + if (ref($elem)) + { + my $type = $elem->[0]; + if ($type =~ /^head(\d+)$/) + { + return $1; + } + else + { + return 0; + } + } + else + { + return 0; + } +} + +sub _makeIndex { + my $self = shift; + + $self->{FirstAnchor} = "TOP"; + my $string = "\n

      Index

      \n
        \n"; + $self->{FirstAnchor} = "TOP"; + my $i = 0; + my $previous_level = 0; + for (my $i=0;$i< @{$self->{sections}} ; $i++) + { + local $_ = $self->{sections}->[$i]; + my $next = ($self->{'sections'}->[$i+1] || ""); + if (ref $_) { + my ($type, $href, $name) = @$_; + my $index_link = ""; + my $next_level = _get_elem_level($next); + my $this_level = _get_elem_level($_) || $previous_level; + if ($this_level < $previous_level) + { + $index_link .= + ("
      \n
    • \n" x ($previous_level - $this_level)); + } + + $index_link .= qq(\t
    • ${name}); + + if ($next eq "OVER") + { + $index_link .= "
      \n"; + } + elsif ($next_level > $this_level) + { + $index_link .= "
      \n"; + $index_link .= + ("
        \n
      • \n" x ($next_level - $this_level - 1)) . + "
          \n"; + } + else + { + $index_link .= "\n"; + } + # $index_link = qq(
            $index_link
          ) unless ($type eq 'head1'); + $string .= $index_link; + } elsif ($_ eq 'OVER') { + $string .= qq(\t
            \n); + } elsif ($_ eq 'BACK') { + $string .= qq(\t
          \n\n); + } + $previous_level = _get_elem_level($_) || $previous_level; + } + $string .= + ("
        \n
      • \n" x ($previous_level-1)) . "
      \n"; + + $string .= "
      \n\n\n"; + return $string; +} + +sub _makeMeta { + my $self = shift; + return + qq(\t\n) + . qq(\t\n) + . qq(\t\n) + . qq(\t\n); +} + +sub _setTitle { + my $self = shift; + my $paragraph = shift; + + if ($paragraph =~ m/^(.+?) - /) { + $self->{doctitle} = $1; + } elsif ($paragraph =~ m/^(.+?): /) { + $self->{doctitle} = $1; + } elsif ($paragraph =~ m/^(.+?)\.pm/) { + $self->{doctitle} = $1; + } else { + $self->{doctitle} = substr($paragraph, 0, 80); + } + $self->{titleflag} = 0; +} + +sub _htmlEscape { + my $txt = shift; + $txt =~ s/&(?!(amp|lt|gt|quot);)/&/g; + $txt =~ s//>/g; + $txt =~ s/\"/"/g; + return $txt; +} + +########## Sequence handlers +sub seqI { return '' . $_[1] . ''; } +sub seqB { return '' . $_[1] . ''; } +sub seqC { return '' . $_[1] . ''; } +sub seqF { return '' . $_[1] . ''; } +sub seqZ { return ''; } + +sub seqL { + my ($self, $link) = @_; + $self->{LinkParser}->parse( $link ); + + my $kind = $self->{LinkParser}->type; + my $string = ''; + + if ($kind eq 'hyperlink') { #easy, a hyperlink + my $targ = _htmlEscape( $self->{LinkParser}->node ); + my $text = _htmlEscape( $self->{LinkParser}->text ); + $string = qq($text); + } elsif ($self->{LinkParser}->page eq '') { # a link to this page + # Post-process these links so we can things up to the correct sections + my $targ = $self->{LinkParser}->node; + my $text = _htmlEscape( $self->{LinkParser}->text ); + $string = qq($text); + } elsif ($kind eq 'item') { # link to the other page + my $targ = $self->_resolvePage($self->{LinkParser}->page); + my $node = $self->{LinkParser}->node; + my $text = _htmlEscape( $self->{LinkParser}->text ); + $string = qq($text); + } else { + my $targ = $self->_resolvePage($self->{LinkParser}->page); + my $text = _htmlEscape( $self->{LinkParser}->text ); + $string = qq($text); + } + return $string; +} + +sub _resolvePage { + my ($self, $page) = @_; + my $modules = $self->local_modules->{ $self->language } || []; + foreach my $module ( @$modules ) { + if ( $module->{name} eq $page ) { + my $targ = $self->_resolveRelPath( $module->{path} ); + return $targ; + } + } + return $self->_makeLinkToCommunity($page); +} + +sub _makeLinkToCommunity { "abstract method" } + +sub _resolveRelPath { + my ($self, $path ) = @_; + my $curpath = $self->current_files_output_path; + my ($name, $dir) = File::Basename::fileparse $curpath, qr/\.html/; + return File::Spec->abs2rel($path, $dir); +} + +sub seqS { + my $text = $_[1]; + $text =~ s/\s/ /g; + return $text; +} + +sub seqX { + my $self = shift; + my $arg = shift; + my $anchor = $self->_addSection( 'head1', $arg ); + return qq[$arg]; +} + +sub seqE { + my $self = shift; + my $arg = shift; + my $rv; + + if ($arg eq 'sol') { + $rv = '/'; + } elsif ($arg eq 'verbar') { + $rv = '|'; + } elsif ($arg =~ /^\d$/) { + $rv = "&#$arg;"; + } elsif ($arg =~ /^0?x(\d+)$/) { + $rv = $1; + } else { + $rv = "&$arg;"; + } + return $rv; +} + +sub gen_html { + my($self, %args) = @_; + my $doc = $args{doc}; + my $components = $args{components}; + my $mgr_desc = $args{desc}; + open(FILE, $doc->origin) or warn $!; + while() { + next unless /^\s*sub\s+(\w+)/; + my $method = $1; + my $sub = $_; + while(){ + $sub .= $_; + last if /^}/; + } + my $result = $self->highlighten("perl", $sub); + $self->{_source_code}{$method} = $result; + } + close(FILE); + $self->current_files_output_path( $doc->get_output_path ); + $self->_prepare($doc, $components, $mgr_desc); +# local $SIG{__WARN__} = sub { }; + $self->parse_from_file($doc->origin); + my $title = $self->_get_title; + $doc->title($title); + $self->current_files_output_path(''); + return $self->asString; +} + +sub _prepare { + my($self, $doc, $components, $mgr_desc) = @_; + my $charset = $doc->config->charset || 'UTF-8'; + $self->{StringMode} = 1; + $self->{MakeMeta} = 0; + $self->{TopLinks} = $components->{arrow}->tag($doc); + $self->{MakeIndex} = $doc->config->index; + $self->{Lang} = $doc->config->lang; + $self->initialize(); + $self->addHeadText($components->{css}->tag($doc)); + $self->addHeadText(qq|\n|); + $self->addHeadText(q| |); + $self->addBodyOpenText($self->_get_data($doc, $mgr_desc)); + $self->addBodyCloseText( + qq|| + ); +} + +sub _get_title { + my $self = shift; + my $name_node = 0; + my $title = ''; + foreach my $node ( @{ $self->parse_tree } ) { + if ($node->{'-ptree'}[0] && $node->{'-ptree'}[0] eq 'NAME') { + $name_node = 1; next; + } + if($name_node == 1){ + $title = join "", @{ $node->{'-ptree'} }; + last; + } + } + $title =~ s/^\s*\S*\s*-\s(.*)$/$1/; + return $title; +} + +sub _get_data { + my($self, $doc, $mgr_desc) = @_; + my $tt = Pod::ProjectDocs::Template->new; + my $text = $tt->process($doc, $doc->data, { + title => $doc->config->title, + desc => $doc->config->desc, + name => $doc->name, + outroot => $doc->config->outroot, + src => $doc->get_output_src_path, + mgr_desc => $mgr_desc, + }); + return $text; +} + + +1; +__END__ + diff --git a/lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm b/lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm new file mode 100644 index 0000000..cdd1df1 --- /dev/null +++ b/lib/Pod/ProjectDocs/Parser/JavaScriptPod.pm @@ -0,0 +1,15 @@ +package Pod::ProjectDocs::Parser::JavaScriptPod; +use strict; +use warnings; +use base qw/Pod::ProjectDocs::Parser/; +use URI::Escape; +__PACKAGE__->language('javascript'); + +sub _makeLinkToCommunity { + my ($self, $page) = @_; + return "http://www.openjsan.org/go/?t=l&q=" . URI::Escape::uri_escape($page); +} + +1; +__END__ + diff --git a/lib/Pod/ProjectDocs/Parser/PerlPod.pm b/lib/Pod/ProjectDocs/Parser/PerlPod.pm new file mode 100644 index 0000000..b07f22e --- /dev/null +++ b/lib/Pod/ProjectDocs/Parser/PerlPod.pm @@ -0,0 +1,15 @@ +package Pod::ProjectDocs::Parser::PerlPod; +use strict; +use warnings; +use base qw/Pod::ProjectDocs::Parser/; +use URI::Escape; +__PACKAGE__->language('perl'); + +sub _makeLinkToCommunity { + my ($self, $page) = @_; + return "http://search.cpan.org/perldoc?" . URI::Escape::uri_escape($page); +} + +1; +__END__ + diff --git a/lib/Pod/ProjectDocs/Template.pm b/lib/Pod/ProjectDocs/Template.pm new file mode 100644 index 0000000..df422b5 --- /dev/null +++ b/lib/Pod/ProjectDocs/Template.pm @@ -0,0 +1,53 @@ +package Pod::ProjectDocs::Template; +use strict; +use warnings; +use Template; +use File::Basename; +use File::Spec; + +sub new { + my $class = shift; + my $self = bless { }, $class; + $self->_init(@_); + return $self; +} + +sub _init { + my $self = shift; + $self->{_curpath} = ''; + $self->{_tt} = Template->new( { + FILTERS => { + relpath => sub { + my $path = shift; + my $curpath = $self->{_curpath}; + my($name, $dir) = fileparse $curpath, qr/\.html/; + return File::Spec->abs2rel($path, $dir); + }, + return2br => sub { + my $text = shift; + $text =~ s!\r\n!
      !g; + $text =~ s!\n!
      !g; + return $text; + } + }, + } ); +} + +sub process { + my($self, $doc, $data, $output) = @_; + $self->{_curpath} = $doc->get_output_path; + $self->{_tt}->process(\$data, $output, \my $text) + or $self->_croak($self->{_tt}->error); + $self->{_curpath} = ''; + return $text; +} + +sub _croak { + my($self, $msg) = @_; + require Carp; + Carp::croak($msg); +} + +1; +__END__ + diff --git a/t/00_compile.t b/t/00_compile.t new file mode 100644 index 0000000..ad081ac --- /dev/null +++ b/t/00_compile.t @@ -0,0 +1,4 @@ +use strict; +use Test::More tests => 1; + +require_ok "Pod::ProjectDocs"; diff --git a/t/01_project.t b/t/01_project.t new file mode 100644 index 0000000..0ed971a --- /dev/null +++ b/t/01_project.t @@ -0,0 +1,20 @@ +use strict; +use FindBin; +use Test::More 'no_plan'; +use Pod::ProjectDocs; + +Pod::ProjectDocs->new( + outroot => "$FindBin::Bin/output", + libroot => "$FindBin::Bin/sample/lib", + forcegen => 1, +)->gen; + +# using XML::XPath might be better +open my $fh, "$FindBin::Bin/output/Sample/Project.pm.html"; +my $html = join '', <$fh>; + +like $html, qr!See SYNOPSIS for its usage!; +like $html, qr!http://www.perl.org/!; +like $html, qr!Perl POD Syntax!; + + diff --git a/t/02_module.t b/t/02_module.t new file mode 100644 index 0000000..f9570f0 --- /dev/null +++ b/t/02_module.t @@ -0,0 +1,23 @@ +use strict; +use FindBin; +use Test::More 'no_plan'; +use Pod::ProjectDocs; + +$Pod::ProjectDocs::Parser::METHOD_REGEXP = qr/^(?:[^=]*=)?\s*(\w+)(?:\(.+\))?/; + +Pod::ProjectDocs->new( + outroot => "$FindBin::Bin/output", + libroot => "$FindBin::Bin/sample/lib2", + forcegen => 1, +)->gen; + +# using XML::XPath might be better +open my $fh, "$FindBin::Bin/output/Module.pm.html"; +my $html = join '', <$fh>; + +like $html, qr!# foo foo foo!; +like $html, qr!# bar bar bar!; +like $html, qr!>\$foo = foo\(\@_\)bar + diff --git a/t/sample/lib/Sample/Project.pm b/t/sample/lib/Sample/Project.pm new file mode 100644 index 0000000..cbe5a9c --- /dev/null +++ b/t/sample/lib/Sample/Project.pm @@ -0,0 +1,21 @@ +package Sample::Project; + +1; + +__END__ + +=head1 NAME + +Sample::Project - Sample project for testing Pod::ProjectDocs + +=head1 SYNOPSIS + + blah blah blah + +=head1 DESCRIPTION + +I. See L for its usage and L for Sample::Module. + +=head1 SEE ALSO + +L, L, L, L, L diff --git a/t/sample/lib2/Module.pm b/t/sample/lib2/Module.pm new file mode 100644 index 0000000..fe759a4 --- /dev/null +++ b/t/sample/lib2/Module.pm @@ -0,0 +1,36 @@ +package Sample::Module; + +sub foo { + # foo foo foo +} + +sub bar { + # bar bar bar +} + +1; + +__END__ + +=head1 NAME + +Sample::Module - Sample Module + +=head1 SYNOPSIS + + blah blah blah + +=head1 MODULES + +=head2 $foo = foo(@_) + +foo foo foo + +=head2 bar + +bar bar bar + +=head1 SEE ALSO + +L +