📄 docsystem.cpp
字号:
CreateHHCEndSection(stream); break; } default: { wxASSERT( FALSE ); break; } } } node = node->Next(); } // CreateHHCPackagesSection(wxT("Packages"), wxEmptyString, stream, docDir); CreateHHCWriteFooter(stream);#if 0 // def __WXGTK__ // Hack to restore correct colour to short description window ecShortDescriptionWindow* sdw = wxGetApp().GetMainFrame()->GetShortDescriptionWindow(); wxColour oldColour = sdw->GetBackgroundColour(); if (oldColour.Ok()) { sdw->SetBackgroundColour(*wxBLACK); sdw->SetBackgroundColour(oldColour); }#endif return TRUE;}static bool ecDirectoryWriteable(const wxString& dir){ // See if we can write to it wxString sep(wxFILE_SEP_PATH); wxString testFile = dir + sep + wxT("_test.tmp"); bool ok = FALSE; { wxLogNull log; wxFile file; ok = file.Create(testFile) ; if (ok) { file.Close(); wxRemoveFile(testFile); } } return ok;}// Find appropriate destination directory for writing files towxString ecHtmlIndexer::FindIndexFilesDir(const wxString& reposDir){ wxString sep(wxFILE_SEP_PATH); // First try install dir wxString dir = reposDir;#ifdef __WXMSW__ if (!ecDirectoryWriteable(dir)) { // Try temp directory as a last resort if (!wxGetEnv(wxT("TEMP"), & dir)) { dir = wxT("c:\\temp"); } return dir; } else { return dir; }#else if (!ecDirectoryWriteable(dir)) { dir = wxGetHomeDir(); if (!ecDirectoryWriteable(dir)) { // Try temp directory as a last resort if (!wxGetEnv(wxT("TEMP"), & dir)) { dir = wxT("/tmp"); } } else { wxString ecosDir = dir + sep + wxT(".eCosDocs"); if (!wxDirExists(ecosDir)) { wxMkdir(ecosDir); } wxString name(ecMakeNameFromPath(reposDir)); wxString ecosVerDir = ecosDir + sep + name; if (!wxDirExists(ecosVerDir)) { wxMkdir(ecosVerDir); } dir = ecosVerDir; } return dir; } else { return dir; }#endif}//// Operations on itemsvoid ecHtmlIndexer::AddIndexByClass(const wxString& title, const wxString& urlToShow, const wxString& urlToExamine, int startIndent){ m_indexItems.Append(new ecIndexItem(ecIndexByClass, title, urlToShow, urlToExamine, startIndent));}void ecHtmlIndexer::AddIndexByList(const wxString& title, const wxString& urlToShow, const wxString& urlToExamine, int startIndent){ m_indexItems.Append(new ecIndexItem(ecIndexByList, title, urlToShow, urlToExamine, startIndent));}void ecHtmlIndexer::AddIndexItem(const wxString& title, const wxString& urlToShow, int startIndent){ m_indexItems.Append(new ecIndexItem(ecIndexNoParse, title, urlToShow, wxEmptyString, startIndent));}void ecHtmlIndexer::AddStartSection(const wxString& title, const wxString& urlToShow){ m_indexItems.Append(new ecIndexItem(ecIndexStartSection, title, urlToShow, wxEmptyString));}void ecHtmlIndexer::AddEndSection(){ m_indexItems.Append(new ecIndexItem(ecIndexEndSection, wxEmptyString, wxEmptyString, wxEmptyString));}void ecHtmlIndexer::ClearItems(){ wxNode* node = m_indexItems.First(); while (node) { ecIndexItem* item = (ecIndexItem*) node->Data(); delete item; node = node->Next(); } m_indexItems.Clear();}// Set m_useOldDocs to TRUE if we find old-style docsbool ecHtmlIndexer::CheckDocEra(const wxString& reposDir){ // We look for tutorials/arm/ecos-tutorial.1.html to see if it's old-style wxString sep(wxFILE_SEP_PATH); wxString docDir(reposDir + sep + wxString(wxT("doc"))) ; // The CVS repository has an HTML subdirectory, but the // packaged version doesn't if (wxDirExists(docDir + sep + wxT("html"))) docDir = docDir + sep + wxString(wxT("html")); wxString armTutorial = docDir + sep + wxString(wxT("tutorials")) + sep + wxString(wxT("arm")) + sep + wxString(wxT("ecos-tutorial.1.html")) ; m_useOldDocs = wxFileExists(armTutorial); return m_useOldDocs;}// Top-level function: generate appropriate index files// and place them either in the install directory or if that is read-only,// in the user's .eCos directory.// Returns TRUE and the created project file if successfulbool ecHtmlIndexer::IndexDocs(const wxString& reposDir, wxString& projectFile, bool force){ CheckDocEra(reposDir); if (UseOldDocs()) { // Old-style docs, where HTML is mostly generated from PageMaker AddStartSection(wxT("Getting Started with eCos"), wxT("")); AddIndexByClass(wxT("AM31-33"), wxT("tutorials/am31-33/ecos-tutorial.1.html"), wxT("tutorials/am31-33/ecos-tutorial.2.html")); AddIndexByClass(wxT("ARM"), wxT("tutorials/arm/ecos-tutorial.1.html"), wxT("/tutorials/arm/ecos-tutorial.2.html")); AddIndexByClass(wxT("i386 PC"), wxT("tutorials/i386pc/ecos-tutorial.1.html"), wxT("tutorials/i386pc/ecos-tutorial.2.html")); AddIndexByClass(wxT("PowerPC"), wxT("tutorials/ppc/ecos-tutorial.1.html"), wxT("tutorials/ppc/ecos-tutorial.2.html")); AddIndexByClass(wxT("SH-3"), wxT("tutorials/sh3/ecos-tutorial.1.html"), wxT("tutorials/sh3/ecos-tutorial.2.html")); AddIndexByClass(wxT("SPARClite"), wxT("tutorials/sparclite/ecos-tutorial.1.html"), wxT("tutorials/sparclite/ecos-tutorial.2.html")); AddIndexByClass(wxT("MIPS"), wxT("tutorials/mips/ecos-tutorial.1.html"), wxT("tutorials/mips/ecos-tutorial.2.html")); AddIndexByClass(wxT("V850"), wxT("tutorials/v850/ecos-tutorial.1.html"), wxT("tutorials/v850/ecos-tutorial.2.html")); AddEndSection(); AddIndexByClass(wxT("eCos User's Guide"), wxT("guides/user-guides.1.html"), wxT("guides/user-guides.2.html")); AddIndexByList(wxT("RedBoot User's Guide"), wxT("redboot/redboot.html"), wxT("redboot/redboot.html")); AddIndexByClass(wxT("Linux Configuration Tool Guide"), wxGetApp().GetFullAppPath(wxT("manual/user-guides.4.html")), wxGetApp().GetFullAppPath(wxT("manual/user-guides.2.html"))); AddIndexByList(wxT("eCos Component Writer's Guide"), wxT("cdl/cdl-guide.html"), wxT("cdl/cdl-guide.html")); AddIndexByClass(wxT("eCos Reference Manual"), wxT("ref/ecos-ref.1.html"), wxT("ref/ecos-ref.2.html")); AddIndexByClass(wxT("eCos-EL/IX Compatibility Guide"), wxT("ecos-elix/ecos-elix.html"), wxT("ecos-elix/ecos-elix.1.html"), 1); AddStartSection(wxT("GNUPro Toolkit Reference Manual")); // Start at indent 1 to avoid a spurious level AddIndexByClass(wxT("ARM"), wxT("ref/gnupro-ref/arm/ARM_COMBO_front.html"), wxT("ref/gnupro-ref/arm/ARM_COMBOTOC.html"), 1); AddIndexByClass(wxT("Fujitsu SPARClite"), wxT("ref/gnupro-ref/sparclite/index.html"), wxT("ref/gnupro-ref/sparclite/index.html")); AddIndexByClass(wxT("Matsushita MN10300"), wxT("ref/gnupro-ref/mn10300/am33_front.html"), wxT("ref/gnupro-ref/mn10300/am33toc.html"), 1); AddIndexByClass(wxT("PowerPC"), wxT("ref/gnupro-ref/powerpc/index.html"), wxT("ref/gnupro-ref/powerpc/index.html")); AddIndexByClass(wxT("Toshiba MIPS TX39"), wxT("/gnupro-ref/tx39/index.html"), wxT("/gnupro-ref/tx39/index.html")); // Don't parse HTML, just add this item, if the page exists. // Presumably the HTML can't be parsed for some reason. AddIndexItem(wxT("Toshiba MIPS TX49"), wxT("ref/gnupro-ref/tx49/tx49_ref.html")); AddIndexByClass(wxT("Hitachi SuperH"), wxT("ref/gnupro-ref/sh/SH_front.html"), wxT("ref/gnupro-ref/sh/SHTOC.html"), 1); AddIndexItem(wxT("NEC V850"), wxT("ref/gnupro-ref/v850/v850_ref_3.html")); AddIndexByClass(wxT("NEC VR4300"), wxT("ref/gnupro-ref/vr4300/Vr43REF_front.html"), wxT("ref/gnupro-ref/vr4300/Vr43REFTOC.html"), 1); AddEndSection(); } else { // NEW-STYLE DOCUMENTATION (HTML is generated from SGML) // Get a list of all tutorials wxArrayString tutorials; wxString sep(wxFILE_SEP_PATH); wxString docDir(reposDir + sep + wxString(wxT("doc"))) ; // The CVS repository has an HTML subdirectory, but the // packaged version doesn't if (wxDirExists(docDir + sep + wxT("html"))) docDir = docDir + sep + wxString(wxT("html")); docDir += sep ; docDir += wxString(wxT("tutorials")); wxLogNull log; wxDir dir(docDir); if (dir.IsOpened()) { wxString filename; bool cont = dir.GetFirst(& filename, wxT("*"), wxDIR_DIRS); while (cont) { if (filename != wxT(".") && filename != wxT("..")) tutorials.Add(filename); cont = dir.GetNext(& filename); } }// AddStartSection(wxT("Getting Started with eCos"), wxT("")); size_t i; for (i = 0; i < tutorials.GetCount(); i++) { wxString tutorial(tutorials[i]); wxString tutorialRelativePath = wxT("tutorials/") + tutorial + wxT("/ecos-tutorial.html"); // Use a more friendly name than just the directory if it's available AddIndexByList(TranslateTutorialDirectory(tutorial), tutorialRelativePath, tutorialRelativePath); }// AddEndSection(); AddIndexByList(wxT("User Guide"), wxT("user-guide/ecos-user-guide.html"), wxT("user-guide/ecos-user-guide.html"));// AddIndexByList(wxT("RedBoot User's Guide"), wxT("redboot/redboot.html"), wxT("redboot/redboot.html"));#ifdef __WXGTK__ // FIXME: wxHtmlParser (version 2.4.0) doesn't like the eCos Reference HTML on Linux so just index the initial page for now AddIndexItem(wxT("eCos Reference"), wxT("ref/ecos-ref.html"));#else AddIndexByList(wxT("eCos Reference"), wxT("ref/ecos-ref.html"), wxT("ref/ecos-ref.html"));#endif AddIndexByList(wxT("Component Writer's Guide"), wxT("cdl-guide/cdl-guide.html"), wxT("cdl-guide/cdl-guide.html"));// AddIndexByList(wxT("eCos-EL/IX Compatibility Guide"), wxT("ecos-elix/elix-compatibility.html"), wxT("ecos-elix/elix-compatibility.html")); //// TOOLCHAIN REFERENCE MANUALS// AddStartSection(wxT("GNUPro Toolkit Reference Manual")); // Start at indent 1 to avoid a spurious level// AddIndexByClass(wxT("ARM"), wxT("ref/gnupro-ref/arm/ARM_COMBO_front.html"), wxT("ref/gnupro-ref/arm/ARM_COMBOTOC.html"), 1);// AddIndexByClass(wxT("Fujitsu SPARClite"), wxT("ref/gnupro-ref/sparclite/index.html"), wxT("ref/gnupro-ref/sparclite/index.html"), 1);// AddIndexByClass(wxT("Matsushita MN10300"), wxT("ref/gnupro-ref/mn10300/am33_front.html"), wxT("ref/gnupro-ref/mn10300/am33toc.html"), 1);// AddIndexByClass(wxT("PowerPC"), wxT("ref/gnupro-ref/powerpc/index.html"), wxT("ref/gnupro-ref/powerpc/index.html"));// AddIndexByClass(wxT("Toshiba MIPS TX39"), wxT("/gnupro-ref/tx39/index.html"), wxT("/gnupro-ref/tx39/index.html")); // Don't parse HTML, just add this item, if the page exists. // Presumably the HTML can't be parsed for some reason.// AddIndexItem(wxT("Toshiba MIPS TX49"), wxT("ref/gnupro-ref/tx49/tx49_ref.html"));// AddIndexByClass(wxT("Hitachi SuperH"), wxT("ref/gnupro-ref/sh/SH_front.html"), wxT("ref/gnupro-ref/sh/SHTOC.html"), 1);// AddIndexItem(wxT("NEC V850"), wxT("ref/gnupro-ref/v850/v850_ref_3.html"));// AddIndexByClass(wxT("NEC VR4300"), wxT("ref/gnupro-ref/vr4300/Vr43REF_front.html"), wxT("ref/gnupro-ref/vr4300/Vr43REFTOC.html"), 1);// AddEndSection(); } DoIndexDocs(reposDir, projectFile, force); return TRUE;}// Some things should be translated in the contentsvoid ecHtmlIndexer::AddEntityTranslation(const wxString& entity, const wxString& translation){ m_entityTableNames.Add(entity); m_entityTableValues.Add(translation);}// Apply all translations to this stringwxString ecHtmlIndexer::TranslateEntities(const wxString& toTranslate){ wxString result(toTranslate); size_t i; for (i = 0; i < m_entityTableNames.GetCount(); i++) { result.Replace(m_entityTableNames[i], m_entityTableValues[i]); } return result;}// Mapping from directory to user-viewable namevoid ecHtmlIndexer::AddTutorialDirectory(const wxString& dirName, const wxString& title){ m_tutorialTableNames.Add(dirName); m_tutorialTableValues.Add(title);}wxString ecHtmlIndexer::TranslateTutorialDirectory(const wxString& dirName){ int i = m_tutorialTableNames.Index(dirName); if (i >= 0) return m_tutorialTableValues[i]; else return dirName;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -