diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-04-29 19:49:07 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2021-04-29 19:49:07 (GMT) |
commit | 4b4489579d31a13b1c4581ad1fe3d7c491fb5816 (patch) | |
tree | 24a35f6ee59ee522eff75d7d9508aca73dd67ab2 /src | |
parent | 3735693b80b6785f9cc16c4e559ca54be8cfbffe (diff) | |
parent | 276a6d144f42979d498c155eebab869bca44f754 (diff) | |
download | Doxygen-4b4489579d31a13b1c4581ad1fe3d7c491fb5816.zip Doxygen-4b4489579d31a13b1c4581ad1fe3d7c491fb5816.tar.gz Doxygen-4b4489579d31a13b1c4581ad1fe3d7c491fb5816.tar.bz2 |
Merge branch 'feature/bug_xml_settings' of https://github.com/albert-github/doxygen into albert-github-feature/bug_xml_settings
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h | 5 | ||||
-rw-r--r-- | src/configimpl.h | 30 | ||||
-rw-r--r-- | src/configimpl.l | 121 | ||||
-rw-r--r-- | src/xmlgen.cpp | 15 |
4 files changed, 151 insertions, 20 deletions
diff --git a/src/config.h b/src/config.h index 45fd4f8..1858897 100644 --- a/src/config.h +++ b/src/config.h @@ -61,6 +61,11 @@ namespace Config */ void compareDoxyfile(TextStream &t); + /*! Writes a the used settings of the current configuartion as XML format + * to stream \a t. + */ + void writeXMLDoxyfile(TextStream &t); + /*! Parses a configuration file with name \a fn. * \returns TRUE if successful, FALSE if the file could not be * opened or read. diff --git a/src/configimpl.h b/src/configimpl.h index d90fe8c..0cf909b 100644 --- a/src/configimpl.h +++ b/src/configimpl.h @@ -78,14 +78,16 @@ class ConfigOption protected: virtual void writeTemplate(TextStream &t,bool sl,bool upd) = 0; virtual void compareDoxyfile(TextStream &t) = 0; + virtual void writeXMLDoxyfile(TextStream &t) = 0; virtual void convertStrToVal() {} virtual void emptyValueToDefault() {} virtual void substEnvVars() = 0; virtual void init() {} + virtual bool isDefault() { return true; } - void writeBoolValue(TextStream &t,bool v); - void writeIntValue(TextStream &t,int i); - void writeStringValue(TextStream &t,const QCString &s); + void writeBoolValue(TextStream &t,bool v,bool initSpace = true); + void writeIntValue(TextStream &t,int i,bool initSpace = true); + void writeStringValue(TextStream &t,const QCString &s,bool initSpace = true); void writeStringList(TextStream &t,const StringVector &l); QCString m_spaces; @@ -109,7 +111,8 @@ class ConfigInfo : public ConfigOption m_doc = doc; } void writeTemplate(TextStream &t, bool sl,bool); - void compareDoxyfile(TextStream &){}; + void compareDoxyfile(TextStream &) {} + void writeXMLDoxyfile(TextStream &) {} void substEnvVars() {} }; @@ -133,8 +136,10 @@ class ConfigList : public ConfigOption StringVector getDefault() { return m_defaultValue; } void writeTemplate(TextStream &t,bool sl,bool); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void substEnvVars(); void init() { m_value = m_defaultValue; } + bool isDefault(); private: StringVector m_value; StringVector m_defaultValue; @@ -161,7 +166,9 @@ class ConfigEnum : public ConfigOption void writeTemplate(TextStream &t,bool sl,bool); void convertStrToVal(); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void init() { m_value = m_defValue; } + bool isDefault() { return m_value == m_defValue; } private: std::vector<QCString> m_valueRange; @@ -191,9 +198,11 @@ class ConfigString : public ConfigOption QCString *valueRef() { return &m_value; } void writeTemplate(TextStream &t,bool sl,bool); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void substEnvVars(); void init() { m_value = m_defValue; } - void emptyValueToDefault() { if(m_value.isEmpty()) m_value=m_defValue; }; + void emptyValueToDefault() { if (m_value.isEmpty()) m_value=m_defValue; }; + bool isDefault() { return m_value.stripWhiteSpace() == m_defValue.stripWhiteSpace(); } private: QCString m_value; @@ -224,7 +233,9 @@ class ConfigInt : public ConfigOption void substEnvVars(); void writeTemplate(TextStream &t,bool sl,bool upd); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void init() { m_value = m_defValue; } + bool isDefault() { return m_value == m_defValue; } private: int m_value; int m_defValue; @@ -253,7 +264,9 @@ class ConfigBool : public ConfigOption void setValueString(const QCString &v) { m_valueString = v; } void writeTemplate(TextStream &t,bool sl,bool upd); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void init() { m_value = m_defValue; } + bool isDefault() { return m_value == m_defValue; } private: bool m_value; bool m_defValue; @@ -269,6 +282,7 @@ class ConfigObsolete : public ConfigOption { m_name = name; } void writeTemplate(TextStream &,bool,bool); void compareDoxyfile(TextStream &) {} + void writeXMLDoxyfile(TextStream &) {} void substEnvVars() {} }; @@ -281,6 +295,7 @@ class ConfigDisabled : public ConfigOption { m_name = name; } void writeTemplate(TextStream &,bool,bool); void compareDoxyfile(TextStream &) {} + void writeXMLDoxyfile(TextStream &) {} void substEnvVars() {} }; @@ -481,6 +496,11 @@ class ConfigImpl */ void compareDoxyfile(TextStream &t); + /*! Writes a the used settings of the current configuartion as XML format + * to stream \a t. + */ + void writeXMLDoxyfile(TextStream &t); + void setHeader(const char *header) { m_header = header; } ///////////////////////////// diff --git a/src/configimpl.l b/src/configimpl.l index cf5386e..98b1f5b 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -37,6 +37,7 @@ #include "portable.h" #include "message.h" #include "lang_cfg.h" +#include "language.h" #include "configoptions.h" #include "fileinfo.h" #include "dir.h" @@ -128,18 +129,19 @@ static QCString convertToComment(const QCString &s, const QCString &u) return result; } -void ConfigOption::writeBoolValue(TextStream &t,bool v) +void ConfigOption::writeBoolValue(TextStream &t,bool v,bool initSpace) { - t << " "; + if (initSpace) t << " "; if (v) t << "YES"; else t << "NO"; } -void ConfigOption::writeIntValue(TextStream &t,int i) +void ConfigOption::writeIntValue(TextStream &t,int i,bool initSpace) { - t << " " << i; + if (initSpace) t << " "; + t << i; } -void ConfigOption::writeStringValue(TextStream &t,const QCString &s) +void ConfigOption::writeStringValue(TextStream &t,const QCString &s,bool initSpace) { char c; bool needsEscaping=FALSE; @@ -149,7 +151,7 @@ void ConfigOption::writeStringValue(TextStream &t,const QCString &s) const char *p=se.data(); if (p) { - t << " "; + if (initSpace) t << " "; while ((c=*p++)!=0 && !needsEscaping) needsEscaping = (c==' ' || c== ',' || c=='\n' || c=='\t' || c=='"' || c=='#'); if (needsEscaping) @@ -351,7 +353,7 @@ void ConfigList::writeTemplate(TextStream &t,bool sl,bool) t << "\n"; } -void ConfigList::compareDoxyfile(TextStream &t) +bool ConfigList::isDefault() { auto get_stripped = [](std::string s) { return QCString(s.c_str()).stripWhiteSpace(); }; auto is_not_empty = [get_stripped](std::string s) { return !get_stripped(s).isEmpty(); }; @@ -359,8 +361,7 @@ void ConfigList::compareDoxyfile(TextStream &t) size_t valCnt = std::count_if(m_defaultValue.begin(),m_defaultValue.end(),is_not_empty); if ( valCnt != defCnt) { - writeTemplate(t,TRUE,TRUE); - return; + return false; } auto it1 = m_value.begin(); auto it2 = m_defaultValue.begin(); @@ -375,13 +376,37 @@ void ConfigList::compareDoxyfile(TextStream &t) { if (get_stripped(*it1) != get_stripped(*it2)) // not the default, write as difference { - writeTemplate(t,TRUE,TRUE); - return; + return false; } ++it1; ++it2; } } + return true; +} + +void ConfigList::compareDoxyfile(TextStream &t) +{ + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigList::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='stringlist'"; + t << ">"; + t << "\n"; + for (const auto &p : m_value) + { + QCString s=p.c_str(); + t << " <value>"; + t << "<![CDATA["; + writeStringValue(t,s,false); + t << "]]>"; + t << "</value>\n"; + } + t << " </option>\n"; } void ConfigEnum::writeTemplate(TextStream &t,bool sl,bool) @@ -403,7 +428,19 @@ void ConfigEnum::writeTemplate(TextStream &t,bool sl,bool) void ConfigEnum::compareDoxyfile(TextStream &t) { - if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigEnum::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='string'"; + t << ">"; + t << "<value>"; + writeStringValue(t,m_value,false); + t << "</value>"; + t << "</option>\n"; } void ConfigString::writeTemplate(TextStream &t,bool sl,bool) @@ -425,7 +462,21 @@ void ConfigString::writeTemplate(TextStream &t,bool sl,bool) void ConfigString::compareDoxyfile(TextStream &t) { - if (m_value.stripWhiteSpace() != m_defValue.stripWhiteSpace()) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigString::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='string'"; + t << ">"; + t << "<value>"; + t << "<![CDATA["; + writeStringValue(t,m_value,false); + t << "]]>"; + t << "</value>"; + t << "</option>\n"; } void ConfigInt::writeTemplate(TextStream &t,bool sl,bool upd) @@ -454,7 +505,19 @@ void ConfigInt::writeTemplate(TextStream &t,bool sl,bool upd) void ConfigInt::compareDoxyfile(TextStream &t) { - if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigInt::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='int'"; + t << ">"; + t << "<value>"; + writeIntValue(t,m_value,false); + t << "</value>"; + t << "</option>\n"; } void ConfigBool::writeTemplate(TextStream &t,bool sl,bool upd) @@ -484,7 +547,19 @@ void ConfigBool::writeTemplate(TextStream &t,bool sl,bool upd) void ConfigBool::compareDoxyfile(TextStream &t) { - if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigBool::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='bool'"; + t << ">"; + t << "<value>"; + writeBoolValue(t,m_value,false); + t << "</value>"; + t << "</option>\n"; } void ConfigObsolete::writeTemplate(TextStream &,bool,bool) {} @@ -1117,6 +1192,17 @@ void ConfigImpl::compareDoxyfile(TextStream &t) } } +void ConfigImpl::writeXMLDoxyfile(TextStream &t) +{ + t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"; + t << "<doxyfile xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"doxyfile.xsd\" version=\"" << getDoxygenVersion() << "\" xml:lang=\"" << theTranslator->trISOLang() << "\">\n"; + for (const auto &option : m_options) + { + option->writeXMLDoxyfile(t); + } + t << "</doxyfile>\n"; +} + void ConfigImpl::convertStrToVal() { for (const auto &option : m_options) @@ -2093,6 +2179,11 @@ void Config::compareDoxyfile(TextStream &t) ConfigImpl::instance()->compareDoxyfile(t); } +void Config::writeXMLDoxyfile(TextStream &t) +{ + ConfigImpl::instance()->writeXMLDoxyfile(t); +} + bool Config::parse(const QCString &fileName,bool update) { bool parseRes = ConfigImpl::instance()->parse(fileName,update); diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 8489a3c..86f3081 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -1898,6 +1898,7 @@ void generateXML() ResourceMgr::instance().copyResource("xml.xsd",outputDirectory); ResourceMgr::instance().copyResource("index.xsd",outputDirectory); + ResourceMgr::instance().copyResource("doxyfile.xsd",outputDirectory); QCString fileName=outputDirectory+"/compound.xsd"; std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); @@ -1935,6 +1936,20 @@ void generateXML() } f.close(); + fileName=outputDirectory+"/Doxyfile.xml"; + f.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!f.is_open()) + { + err("Cannot open file %s for writing\n",fileName.data()); + return; + } + else + { + TextStream t(&f); + Config::writeXMLDoxyfile(t); + } + f.close(); + fileName=outputDirectory+"/index.xml"; f.open(fileName.str(),std::ofstream::out | std::ofstream::binary); if (!f.is_open()) |