AppDocScript
Differences between revisions 1 and 3 (spanning 2 versions)
5670
Comment:
|
6140
|
Deletions are marked like this. | Additions are marked like this. |
Line 11: | Line 11: |
== Usage == To run the script, you will need to do the following: 1. Copy it into a file called appdoc.pl 2. In the same directory as the script, create a writable directory called "wiki" 3. Get a copy of the Edubuntu seed files: bzr branch lp:~ubuntu-core-dev/ubuntu-seeds/edubuntu.maverick 4. Run the script: perl ./appdoc.pl edubuntu.maverick/ubuntu-edu-* 5. Copy/Paste from ./wiki/*.moin into http://wiki.ubuntu.com/Edubuntu/AppGuide |
|
Line 13: | Line 23: |
{{{ | {{{#!hilight perl |
Summary
This is the script used to generate Edubuntu/AppGuide and associated pages.
Usage
To run the script, you will need to do the following:
- Copy it into a file called appdoc.pl
- In the same directory as the script, create a writable directory called "wiki"
- Get a copy of the Edubuntu seed files: bzr branch lp:~ubuntu-core-dev/ubuntu-seeds/edubuntu.maverick
- Run the script: perl ./appdoc.pl edubuntu.maverick/ubuntu-edu-*
Copy/Paste from ./wiki/*.moin into http://wiki.ubuntu.com/Edubuntu/AppGuide
Script
#!/usr/bin/perl my @seedFiles = @ARGV || fail("No Seed File given"); my $listFile = 'wiki/AppGuides.moin'; open(G, '>', $listFile) || die "Could not open $listFile\n$!"; for my $seedFile (@ARGV) { print G "== $seedFile ==\n"; my @packages = packages($seedFile); for my $p (@packages) { print "Reading Package: ", $p, "\n"; my $aptinfo = aptinfo($p); writepage($aptinfo); print G " * [[Edubuntu/AppGuides/$p|$p]] - ", $aptinfo->{'shortDescription'}, "\n"; } print G "\n"; } close(G); sub fail { my $msg = shift; print STDERR $msg, "\n"; usage(STDERR); exit 1; } sub usage { my $out = shift || STDOUT; print $out "Usage: ./appdoc.pl seed_file\n\n"; } sub packages { my $seedFile = shift || die "No Seed file given to sub: packages"; open(S, '<', $seedFile) || die "Could not open seed file: $seedFile\n$!"; my @packages = (); while (my $line = <S>) { if ($line =~ /^\s+\*\s+([a-zA-z0-9_-]+)/) { push(@packages, $1); } } close(S); return @packages; } sub aptinfo { my $package = shift || die "No Package name given to sub: aptinfo"; my %info = (); open(A, '-|', "apt-cache show $package") || die "Could not open apt-cache for reading $package\n$!"; my $inDesc = 0; while (my $line = <A>){ chomp $line; if ($inDesc > 0 && substr($line, 0, 1) eq ' ') { if ($line eq " .") { $info{'Description'} .= "\n "; } else { $info{'Description'} .= "\n" . substr($line, 1); } } else { $inDesc = 0; my ($key, $val) = split(': ', $line, 2); if ($key eq 'Description') { $inDesc = 1; $info{'shortDescription'} = $val; } else { $info{$key} = $val; } } } close(A); return \%info; } sub sections { my $info = shift || die "No Package Info given to sub: sections"; my %sections = (); for my $section (split('/', $info->{'Section'})) { unless ($section =~ m/(main|restricted|universe|multiverse)/) { if ($section =~ /(science|education|math)/i) { $sections{'Educational'} = 1; } elsif ($section =~ /(game|entertainment)/i) { $sections{'Game'} = 1; } else { $sections{$section} = 1; } } } return keys %sections; } sub languages { my $info = shift || die "No Package Info given to sub: languages"; my %langs = (); if ($info->{'Depends'} =~ /libc[^a-zA-Z]/i) { $langs{'C'} = 1; } if ($info->{'Depends'} =~ /libstdc\+\+/i) { $langs{'C++'} = 1; } if ($info->{'Depends'} =~ /python/i) { $langs{'Python'} = 1; } if ($info->{'Depends'} =~ /ruby/i) { $langs{'Ruby'} = 1; } if ($info->{'Depends'} =~ /(java|jvm)/i) { $langs{'Java'} = 1; } return keys %langs; } sub toolkits { my $info = shift || die "No Package Info given to sub: toolkits"; my %tk = (); if ($info->{'Depends'} =~ /gtk/i) { $tk{'GTK'} = 1; } if ($info->{'Depends'} =~ /qt/i) { $tk{'QT'} = 1; } if ($info->{'Depends'} =~ /gnome/i) { $tk{'Gnome'} = 1; } if ($info->{'Depends'} =~ /kde/i) { $tk{'KDE'} = 1; } if ($info->{'Depends'} =~ /libsdl/i) { $tk{'SDL'} = 1; } return keys %tk; } sub writepage { my $info = shift || die "No Package Info given to sub: writepage"; my $pagefile = 'wiki/'.$info->{'Package'}.'.moin'; open(P, '>', $pagefile) || die "Could not open file for writing: $pagefile\n$!"; my $package = $info->{'Package'}; my $screenshot = "http://screenshots.debian.net/screenshot/$package"; my $type = join(', ', sections($info)); my $desc = $info->{'Description'} || ''; my $langs = join(', ', languages($info)); my $tk = join(', ', toolkits($info)); my $launchpad = "https://launchpad.net/ubuntu/maverick/+source/$package"; my $homepage = $info->{'Homepage'} || ''; my $short = $info->{'shortDescription'} || ''; print P <<EOF; ##master-page:Edubuntu/AppTemplate #format wiki #language en #title $package ||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>|| $short == Summary == $desc == Technical Details == || Type || $type || || Age Range || Recommended age range || || Profile || Edubuntu profile(s) that include this || || Website || $homepage || || Launchpad || $launchpad || || License || License(s) the application is available under || || Language || $langs || || Toolkit || $tk || == Screenshots == {{$screenshot|$package Screenshot}} If a screen shot is not available, submit your own according to the debian screenshot [[http://screenshots.debian.net/upload|guidelines]]. == User Comments == This space is for users to share their experiences and opinions about the application EOF close(P); }
Edubuntu/AppGuide/AppDocScript (last edited 2012-05-24 15:24:43 by mhall119)