Get package things working with modules prior to UI patch.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19900 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2007-08-29 22:59:25 +00:00
parent 8239945aa7
commit 7f17f13bfc
3 changed files with 26 additions and 16 deletions

View File

@ -765,7 +765,7 @@ def processModuleFile(file, bool_docbook, bool_linuxdoc):
Declare lines look like this: Declare lines look like this:
\DeclareLyXModule[LaTeX Packages]{Description}{ModuleName}... \DeclareLyXModule[LaTeX Packages]{Description}{ModuleName}...
We expect output: We expect output:
"ModuleName" "filename" "Description" "ModuleName" "filename" "Description" "Packages"
" "
''' '''
p = re.compile(r'\DeclareLyXModule\s*(?:\[([^]]*)\])?{(.*)}{(.*)}') p = re.compile(r'\DeclareLyXModule\s*(?:\[([^]]*)\])?{(.*)}{(.*)}')
@ -774,17 +774,14 @@ def processModuleFile(file, bool_docbook, bool_linuxdoc):
if res != None: if res != None:
(packages, desc, modname) = res.groups() (packages, desc, modname) = res.groups()
#check availability...need to add that #check availability...need to add that
if modname == None: if packages == None:
modname = desc
desc = packages
packages = "" packages = ""
elif packages != None: else:
pkgs = [s.strip() for s in packages.split(",")] pkgs = [s.strip() for s in packages.split(",")]
packages = ",".join(pkgs) packages = ",".join(pkgs)
filename = file.split(os.sep)[-1] filename = file.split(os.sep)[-1]
#return '"%s" "%s" "%s" "%s"\n' % (modname, filename, desc, '.'.join(pkgs)) return '"%s" "%s" "%s" "%s"\n' % (modname, filename, desc, packages)
return '"%s" "%s" "%s"\n' % (modname, filename, desc)
print "Module file without \DeclareLyXModule line. " print "Module file without \DeclareLyXModule line. "
sys.exit(2) sys.exit(2)

View File

@ -13,8 +13,9 @@
#include "debug.h" #include "debug.h"
#include "Lexer.h" #include "Lexer.h"
#include "ModuleList.h" #include "ModuleList.h"
#include "support/filetools.h"
#include "support/docstring.h" #include "support/docstring.h"
#include "support/filetools.h"
#include "support/lstrings.h"
namespace lyx{ namespace lyx{
@ -93,10 +94,20 @@ bool ModuleList::load() {
if (lex.next()) { if (lex.next()) {
string const desc = lex.getString(); string const desc = lex.getString();
LYXERR(Debug::TCLASS) << "Description: " << desc << endl; LYXERR(Debug::TCLASS) << "Description: " << desc << endl;
//FIXME Add package read, and availability //FIXME Add packages
// This code is run when we have if (lex.next()) {
// modName, fname, and desc string packages = lex.getString();
addLayoutModule(modName, fname, desc); LYXERR(Debug::TCLASS) << "Packages: " << packages << endl;
vector<string> pkgs;
while (!packages.empty()) {
string p;
packages = support::split(packages, p, ',');
pkgs.push_back(p);
}
// This code is run when we have
// modName, fname, desc, and pkgs
addLayoutModule(modName, fname, desc, pkgs);
}
} }
} }
} // end switch } // end switch
@ -111,11 +122,12 @@ bool ModuleList::load() {
void ModuleList::addLayoutModule(string moduleName, void ModuleList::addLayoutModule(string moduleName,
string filename, string description) { string filename, string description, vector<string> pkgs) {
LyXModule lm; LyXModule lm;
lm.name = moduleName; lm.name = moduleName;
lm.filename = filename; lm.filename = filename;
lm.description = description; lm.description = description;
lm.packageList = pkgs;
modlist_.push_back(lm); modlist_.push_back(lm);
} }

View File

@ -34,9 +34,9 @@ namespace lyx {
/// a short description for use in the ui /// a short description for use in the ui
std::string description; std::string description;
/// the LaTeX packages on which this depends, if any (not implemented) /// the LaTeX packages on which this depends, if any (not implemented)
//std::vector<std::string> packageList; std::vector<std::string> packageList;
/// whether those packages are available (not implemented yet) /// whether those packages are available (not implemented yet)
//bool available; bool available;
}; };
typedef std::vector<LyXModule> LyXModuleList; typedef std::vector<LyXModule> LyXModuleList;
@ -51,7 +51,8 @@ namespace lyx {
bool load(); bool load();
/// add a module to the list /// add a module to the list
void addLayoutModule(std::string name, std::string filename, void addLayoutModule(std::string name, std::string filename,
std::string description); std::string description,
std::vector<std::string> packages);
/// ///
LyXModuleList::const_iterator begin() const; LyXModuleList::const_iterator begin() const;
/// ///