📄 mk_dir_modules.pl
字号:
#!/usr/bin/perl -w# mkdirreadme - a very simple document-extractor for subdirs..## 04/03/08 - ineiti - imported from mkreadme.pl and adjusted for directoriesif ( $#ARGV < 0 ){ die "Give the directory name as argument"}$dirs = `ls $ARGV[0]`;$dirs =~ s/\n/ /g;foreach $dir ( `find $dirs -type d -maxdepth 0 | grep -v CVS` ){ chomp( $dir ); if ( -e "$dir/Makefile" ){ getDescription( $dir ); }}# Tries to look at the directory and to decide what to do..sub getDescription{ my $d = shift; my $make = `cat $d/Makefile`; my ($name) = ( $make =~ /MODULE_NAME\s*=\s*(\w*)/ ); my $main = "$d/$name.c"; # if the file defined in the MAKEFILE doesn't exist, we still can # try to find a file that contains "^module_init", which would qualify # it as the main-file... if ( !stat( $main ) ){ my $main_old = $main; $main = `grep -l "^module_init.*(" $d/*c`; chop( $main ); if ( !stat( $main ) ){ die( "Hmm, $main_old doesn't exist and there seems to be no module\n". "declaring module_init... This is BAD\n" ); } } print $name, "\n"; print "-" x length( $name ) . "\n"; print getMain( $main ) . "\n\n\n"; return;}# Searches for a comment on the module. The idea is that the# first /** starts a comment, and that all other headers have# a /\*{3,} to begin with.sub getDesc{ my $file = shift; my ( $desc ) = ( $file =~ /\/\*\*([^\*].*?)\*\//s ); $desc =~ s/\n\s*\*( |)/\n/g; $desc =~ s/\s*$//; return $desc;}# Reads the comment of the main-modulesub getMain{ my $fname = shift; open( SOURCE, "<$fname" ) || die ( "Couldn't open input-file $!\n" ); undef $/; my $file = <SOURCE>; my $desc = getDesc( $file ); $/ = "\n"; return $desc;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -