1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 //===========================================================================
26 //#####DESCRIPTIONBEGIN####
29 // Contact(s): julians
33 // Description: Classes for the Configtool documentation system
40 //####DESCRIPTIONEND####
42 //===========================================================================
44 #ifndef _EC_DOCSYSTEM_H_
45 #define _EC_DOCSYSTEM_H_
48 #pragma interface "docsystem.cpp"
51 #include "htmlparser.h"
53 enum ecIndexType { ecIndexByClass, ecIndexByList, ecIndexNoParse, ecIndexStartSection, ecIndexEndSection } ;
57 * A class to parse files and generate suitable MS Html Help/wxHTML Help compatible
58 * project, contents and keyword files.
61 class ecHtmlIndexer: public wxObject
64 ecHtmlIndexer(bool useRelativeURLs = TRUE);
68 // Top-level function: generate appropriate index files
69 // and place them either in the install directory or if that is read-only,
70 // in the user's .eCos directory
71 // Returns TRUE and the created project file if successful
72 bool IndexDocs(const wxString& reposDir, wxString& projectFile, bool force = TRUE);
74 // Creates the project, contents and keywords files using the ecIndexItems
75 // we previously added.
76 bool DoIndexDocs(const wxString& reposDir, wxString& projectFile, bool force = TRUE);
78 // If tag is an <A HREF...>, write the item by looking at the text between <A> and </A>
79 void CreateHHCOutputItem(wxSimpleHtmlTag* tag, int level, int& indent, const wxString& pathPrefix, const wxString& docDir, wxOutputStream& stream);
81 // Append HHC-compatible code to a stream according to the tags found in the
82 // given HTML file: use P CLASS attributes to determine level.
83 bool CreateHHCByExaminingClass(const wxString& title, const wxString& topURL, const wxString& htmlFile, const wxString& docDir, wxOutputStream& stream, int startIndent = 0);
85 // Append HHC-compatible code to a stream according to the tags found in the
86 // given HTML file: use <DL> </DL> level
87 bool CreateHHCByExaminingList(const wxString& title, const wxString& topURL, const wxString& htmlFile, const wxString& docDir, wxOutputStream& stream, int startIndent = 0);
89 // Just add the given contents item without parsing
90 bool CreateHHCItem(const wxString& title, const wxString& topURL, const wxString& docDir, wxOutputStream& stream, int startIndent = 0);
92 void CreateHHCWriteHeader(wxOutputStream& stream);
93 void CreateHHCWriteFooter(wxOutputStream& stream);
95 // Start a section, which may or may not contain multiple subsections, one per architecture
96 bool CreateHHCStartSection(const wxString& title, const wxString& topURL, const wxString& docDir, wxOutputStream& stream);
97 bool CreateHHCEndSection(wxOutputStream& stream);
99 // Create a section for all the Packages in the system, using the current document/repository
100 bool CreateHHCPackagesSection(const wxString& title, const wxString& topURL, wxOutputStream& stream, const wxString& htmlPath);
102 // Convert redirection to actual filename
103 static wxString Redirect(const wxString& baseName, const wxString& url);
105 // Write the project file
106 bool WriteHHP(const wxString& filename, const wxString& docDir);
108 // Find appropriate destination directory for writing files to
109 wxString FindIndexFilesDir(const wxString& reposDir) ;
111 //// Operations on items
112 void AddIndexByClass(const wxString& title, const wxString& urlToShow, const wxString& urlToExamine, int startIndent = 0);
113 void AddIndexByList(const wxString& title, const wxString& urlToShow, const wxString& urlToExamine, int startIndent = 0);
114 void AddIndexItem(const wxString& title, const wxString& urlToShow, int startIndent = 0);
115 void AddStartSection(const wxString& title, const wxString& urlToShow = wxEmptyString);
116 void AddEndSection();
121 // Some things should be translated in the contents
122 void AddEntityTranslation(const wxString& entity, const wxString& translation);
123 // Apply all translations to this string
124 wxString TranslateEntities(const wxString& toTranslate);
126 // Mapping from directory to user-viewable name
127 void AddTutorialDirectory(const wxString& dirName, const wxString& title);
128 wxString TranslateTutorialDirectory(const wxString& dirName);
131 wxList& GetIndexItems() { return m_indexItems; }
132 bool UseRelativeURLs() const { return m_useRelativeURLs; }
133 bool UseOldDocs() const { return m_useOldDocs; }
137 // Set m_useOldDocs to TRUE if we find old-style docs
138 bool CheckDocEra(const wxString& reposDir) ;
141 // List of ecIndexItems
143 bool m_useRelativeURLs;
144 bool m_useOldDocs; // if TRUE, we have the old-style docs generated by FrameMaker
145 wxArrayString m_entityTableNames; // Translations for awkward symbols not processed by wxHTML or MS HTML Help such as — (--)
146 wxArrayString m_entityTableValues; // values for the above
147 wxArrayString m_tutorialTableNames; // Directory -> title mapping e.g. arm -> ARM, sparclite -> Fujitsu SPARClite
148 wxArrayString m_tutorialTableValues;
151 class ecIndexItem: public wxObject
154 ecIndexItem(ecIndexType type, const wxString& title, const wxString& urlToShow,
155 const wxString& urlToExamine, int startLevel = 0)
157 m_type = type; m_title = title; m_urlToShow = urlToShow;
158 m_urlToExamine = urlToExamine; m_startLevel = startLevel;
163 wxString m_urlToShow;
164 wxString m_urlToExamine;