in reply to POD in XS

As BrowserUk said, you'd generally have a .pm file that loads your XS - you can put your POD documentation into the .pm file.

That said though, it is possible to add pod to an .xs file. Just include the pod in a C comment...

#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" MODULE = Mytest PACKAGE = Mytest void hello() CODE: printf("Hello, world!\n"); /* =head1 NAME Mytest - this is a test! =cut */

Note the start of the comment needs to be indented for the benefit of xsubpp. Not sure if the end of the comment needs to be, but no harm in doing so. Don't forget the =cut.

Now, that gives you pod in XS. You should be able to run something like pod2man on it and it will work. EU:MM will not automatically find the pod there and install it for the end user though. You can probably play some games with Pod::Man in your Makefile.PL.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: POD in XS
by bulk88 (Priest) on Mar 19, 2012 at 20:05 UTC
    So far MAN3PODS is useless or buggy on activeperl's HTML system. Changing the parameters UpdateHTML_blib is possible and suggested in the docs for AP's MM, but I think thats very prone to future breakage. I think I will try to just have a makefile section automatically copy and rename the .xs file to a .pod. I will update this post with my results.
    MAN3PODS => { 'MYXSLIB.xs' => '/blib/man3/MYXSLIB.3'},
    # --- MakeMaker manifypods section: POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" POD2MAN = $(POD2MAN_EXE) manifypods : pure_all \ MYXSLIB.xs $(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) \ MYXSLIB.xs /blib/man3/MYXSLIB.3 # --- MakeMaker htmlifypods section: POD2HTML_EXE = $(PERLRUN) "-MActivePerl::DocTools" -e "UpdateHTML_blib +(installdirs => "$(INSTALLDIRS)")" POD2HTML = $(POD2HTML_EXE) htmlifypods : \ MYXSLIB.xs $(NOECHO) $(POD2HTML)
    Update:

    I found putting this in makefile.pl works with ActivePerl.
    package MY; sub postamble { return ' MoreDocs.pod :: $(CP) $(BASEEXT).xs .\lib\$(FULLEXT)\MoreDocs.pod $(BASEEXT).xs :: MoreDocs.pod '; }