Commit bc0bc0f1 authored by Luigi Toscano's avatar Luigi Toscano

Optional usage of documentationDirs from KDocTools

Summary:
Only if available. Unfortunately a bug in KDocTools prevents for
looking for its version, so use another the version of another core
library part of Frameworks.

Test Plan:
The new code compiles without regression in functionalities:
- the cache is created for toc entries
- the documentation is found.

Reviewers: aacid, cfeck

Reviewed By: aacid

Subscribers: #documentation

Tags: #documentation

Differential Revision: https://phabricator.kde.org/D6790
parent 5a80f834
...@@ -98,6 +98,9 @@ kconfig_add_kcfg_files(khelpcenter_KDEINIT_SRCS prefs.kcfgc ) ...@@ -98,6 +98,9 @@ kconfig_add_kcfg_files(khelpcenter_KDEINIT_SRCS prefs.kcfgc )
kf5_add_kdeinit_executable( khelpcenter ${khelpcenter_KDEINIT_SRCS}) kf5_add_kdeinit_executable( khelpcenter ${khelpcenter_KDEINIT_SRCS})
target_compile_definitions(kdeinit_khelpcenter PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}") target_compile_definitions(kdeinit_khelpcenter PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
target_link_libraries(kdeinit_khelpcenter KF5::KHtml KF5::Service KF5::DBusAddons KF5::ConfigGui KF5::WindowSystem KF5::Bookmarks Qt5::Xml Grantlee5::Templates) target_link_libraries(kdeinit_khelpcenter KF5::KHtml KF5::Service KF5::DBusAddons KF5::ConfigGui KF5::WindowSystem KF5::Bookmarks Qt5::Xml Grantlee5::Templates)
if (${KF5_VERSION} VERSION_GREATER 5.36.0)
target_link_libraries(kdeinit_khelpcenter KF5::DocTools)
endif()
install(TARGETS kdeinit_khelpcenter ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS kdeinit_khelpcenter ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS khelpcenter ${INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS khelpcenter ${INSTALL_TARGETS_DEFAULT_ARGS})
......
...@@ -17,6 +17,9 @@ add_executable(khc_xapianindexer ${khc_xapianindexer_SOURCES}) ...@@ -17,6 +17,9 @@ add_executable(khc_xapianindexer ${khc_xapianindexer_SOURCES})
kde_target_enable_exceptions(khc_xapianindexer PRIVATE) kde_target_enable_exceptions(khc_xapianindexer PRIVATE)
ecm_mark_nongui_executable(khc_xapianindexer) ecm_mark_nongui_executable(khc_xapianindexer)
target_link_libraries(khc_xapianindexer Qt5::Core KF5::Archive ${XAPIAN_LIBRARIES} ${LIBXML2_LIBRARIES}) target_link_libraries(khc_xapianindexer Qt5::Core KF5::Archive ${XAPIAN_LIBRARIES} ${LIBXML2_LIBRARIES})
if (${KF5_VERSION} VERSION_GREATER 5.36.0)
target_link_libraries(khc_xapianindexer KF5::DocTools)
endif()
install(TARGETS khc_xapianindexer DESTINATION ${LIBEXEC_INSTALL_DIR}) install(TARGETS khc_xapianindexer DESTINATION ${LIBEXEC_INSTALL_DIR})
# Xapian search # Xapian search
......
...@@ -23,6 +23,11 @@ ...@@ -23,6 +23,11 @@
#include "htmltextdump.h" #include "htmltextdump.h"
#include "xapiancommon.h" #include "xapiancommon.h"
#include <kcoreaddons_version.h>
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
#include <docbookxslt.h>
#endif
#include <QCoreApplication> #include <QCoreApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QDebug> #include <QDebug>
...@@ -30,6 +35,7 @@ ...@@ -30,6 +35,7 @@
#include <QDirIterator> #include <QDirIterator>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QStandardPaths> #include <QStandardPaths>
#include <QStringBuilder>
namespace { namespace {
...@@ -222,7 +228,22 @@ int main( int argc, char *argv[] ) ...@@ -222,7 +228,22 @@ int main( int argc, char *argv[] )
QSet<Xapian::docid> handledDocuments; QSet<Xapian::docid> handledDocuments;
const std::string std_lang = lang.toStdString(); const std::string std_lang = lang.toStdString();
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
const QStringList docDirs = KDocTools::documentationDirs();
QStringList localDoc;
QStringList::ConstIterator it = docDirs.constBegin();
for ( ; it != docDirs.constEnd(); ++it ) {
const QString docDirLangName = QString( ( *it ) % "/" % lang % "/" );
QFileInfo docDirLang = QFileInfo( docDirLangName );
if ( docDirLang.exists() && docDirLang.isDir() ) {
localDoc << docDirLangName;
}
}
#else
const QStringList localDoc = QStandardPaths::locateAll( QStandardPaths::GenericDataLocation, QStringLiteral("doc/HTML/") + lang + "/", QStandardPaths::LocateDirectory ); const QStringList localDoc = QStandardPaths::locateAll( QStandardPaths::GenericDataLocation, QStringLiteral("doc/HTML/") + lang + "/", QStandardPaths::LocateDirectory );
#endif
qCDebug(LOG) << "documentation directories:" << localDoc; qCDebug(LOG) << "documentation directories:" << localDoc;
Q_FOREACH ( const QString &path, localDoc ) { Q_FOREACH ( const QString &path, localDoc ) {
walkFiles( path, std_lang, db, xgen, &handledDocuments ); walkFiles( path, std_lang, db, xgen, &handledDocuments );
......
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
#include <KProcess> #include <KProcess>
#include <KXmlGuiWindow> #include <KXmlGuiWindow>
#include <kcoreaddons_version.h>
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
#include <docbookxslt.h>
#endif
#include <QStatusBar> #include <QStatusBar>
#include <QFileInfo> #include <QFileInfo>
...@@ -83,7 +88,11 @@ void TOC::build( const QString &file ) ...@@ -83,7 +88,11 @@ void TOC::build( const QString &file )
{ {
QFileInfo fileInfo( file ); QFileInfo fileInfo( file );
QString fileName = fileInfo.absoluteFilePath(); QString fileName = fileInfo.absoluteFilePath();
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
const QStringList resourceDirs = KDocTools::documentationDirs();
#else
const QStringList resourceDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "doc/HTML", QStandardPaths::LocateDirectory); const QStringList resourceDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "doc/HTML", QStandardPaths::LocateDirectory);
#endif
QStringList::ConstIterator it = resourceDirs.begin(); QStringList::ConstIterator it = resourceDirs.begin();
QStringList::ConstIterator end = resourceDirs.end(); QStringList::ConstIterator end = resourceDirs.end();
for ( ; it != end; ++it ) { for ( ; it != end; ++it ) {
......
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
#include <KHTMLView> #include <KHTMLView>
#include <KToolBarPopupAction> #include <KToolBarPopupAction>
#include <KSharedConfig> #include <KSharedConfig>
#include <ki18n_version.h> #include <kcoreaddons_version.h>
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
#include <docbookxslt.h>
#endif
#include <QFileInfo> #include <QFileInfo>
#include <QClipboard> #include <QClipboard>
...@@ -94,8 +97,13 @@ QString View::langLookup( const QString &fname ) ...@@ -94,8 +97,13 @@ QString View::langLookup( const QString &fname )
{ {
QStringList search; QStringList search;
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
// retrieve the local search path
const QStringList localDoc = KDocTools::documentationDirs();
#else
// assemble the local search paths // assemble the local search paths
const QStringList localDoc = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("doc/HTML"), QStandardPaths::LocateDirectory); const QStringList localDoc = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("doc/HTML"), QStandardPaths::LocateDirectory);
#endif
QStringList langs = KLocalizedString::languages(); QStringList langs = KLocalizedString::languages();
langs.append(QStringLiteral("en")); langs.append(QStringLiteral("en"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment