Changeset 1120


Ignore:
Timestamp:
Jun 28, 2011, 11:35:58 PM (6 years ago)
Author:
stefan
Message:

include package description

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/src/jlatexeditor/tools/PackageParser.scala

    r1107 r1120  
    1717  val Input = ".*\\\\input\\{([^}]+)\\}".r
    1818  val DpkgResult = "([\\w\\.-]+): .*".r
     19  val CtanPackSplit = "([^=]+)=(.*)".r
    1920
    2021  val processedFiles = new HashSet[String]
    2122  val files2debPackage = new HashMap[String, DebPackage]
     23  val ctanPackInfos = {
     24    val map = new HashMap[String, CtanPackInfo]
     25
     26    new File("ctan-packages.txt").readLines.foreach( _ match {
     27      case CtanPackSplit(title, desc) => map += title.toLowerCase -> new CtanPackInfo(title, desc.replace("\\.$", ""))
     28    })
     29
     30    map
     31  }
    2232
    2333  def main(args: Array[String]) {
     
    6474    out.println("<packages>")
    6575    for (pack <- packages) {
     76      val ctanPackString = pack.ctanPackInfo.map( pack => " title=\"" + pack.title + "\" description=\"" + pack.desc + "\"").getOrElse("")
    6677      val debPackageString = pack.debPackage.map( pack => " debPackage=\"" + pack.name + "\"").getOrElse("")
    67       out.println("  <package name=\"" + pack.name + "\"" + debPackageString + ">")
     78      out.println("  <package name=\"" + pack.name + "\"" + ctanPackString + debPackageString + ">")
    6879      for (command <- pack.commands.values) {
    6980        val optArgString = if (command.optionalArgs.isEmpty) "" else " optionalArg=\"" + escape(command.optionalArgs(0)) + "\""
     
    168179  class Command(val pack: Package, val name: String, val argCount: Int, val optionalArgs: List[String] = List())
    169180  class Environment(val pack: Package, val name: String, val argCount: Int, val optionalArgs: List[String] = List())
    170   class Package(val file: File, val cls: Boolean, val name: String, val commands: LinkedHashMap[String, Command] = new LinkedHashMap[String, Command],
     181  class Package(val file: File, val cls: Boolean, val name: String,
     182                val commands: LinkedHashMap[String, Command] = new LinkedHashMap[String, Command],
    171183                val environments: LinkedHashMap[String, Environment] = new LinkedHashMap[String, Environment]) {
    172184    val debPackage = try {
     
    175187      case e: FileNotFoundException => None
    176188    }
     189    val ctanPackInfo = ctanPackInfos.get(name.toLowerCase)
    177190  }
     191  class CtanPackInfo(val title: String, val desc: String)
    178192  class DebPackage(val name: String, val files: MutableList[String])
    179193}
Note: See TracChangeset for help on using the changeset viewer.