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

View File

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

View File

@ -34,9 +34,9 @@ namespace lyx {
/// a short description for use in the ui
std::string description;
/// 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)
//bool available;
bool available;
};
typedef std::vector<LyXModule> LyXModuleList;
@ -51,7 +51,8 @@ namespace lyx {
bool load();
/// add a module to the list
void addLayoutModule(std::string name, std::string filename,
std::string description);
std::string description,
std::vector<std::string> packages);
///
LyXModuleList::const_iterator begin() const;
///