2009/5/28 Brian Matherly <brian@gramps-project.org>

Benny,

> I'm writing the docbackend to use in the textdoc
> classes for writing.
> I'd like to move src/BaseDoc.py to
> src/docgen/basedoc.py and perhaps split off textdoc and
> drawdoc classes from it in their own file. Does that fit
> with your view?
>
> You have been moving docgen stuff around a lot in 3.0 and
> 3.1, so I thougth to first ask.

That does align with my view. I've been meaning to get around to it, but the task has been to big for me to tackle. In my vision, BaseDoc.py would be broken into the following files:

basedoc.py:        contains only BaseDoc
paperstyle.py:     contains PaperSize and PaperStyle
fontstyle.py:      contains FontStyle
paragraphstyle.py: contains ParagraphStyle
tablestyle.py:     contains TableStyle and TableCellStyle
stylesheet.py:     contains StyleSheetList, StyleSheet and SheetParser
graphicstyle.py:   contains GraphicsStyle
textdoc.py:        contains TextDoc and IndexMark
drawdoc.py:        contains DrawDoc
graphdoc.py:       contians GVDoc

Of course, this could be accomplished in stages instead of all at once.

The new files should be placed in src/gen/plug somewhere. However, the policy with files in the "gen" directory is that they can not have dependencies outside of the "gen" directory (except for standard python dependencies) so that the "gen" library can stand on its own. BaseDoc.py has the following dependencies: Utils, FontScale, and const. So, to make the move properly, those dependencies should either be removed, or they should also be moved into the "gen" library. "Utils" can not be moved into the "gen" library as it is. So we will need to find a way to remove the dependencies on "Utils". Same goes for const. I'm not sure about "FontScale", but my intuition tells me that it can probably be moved into "gen".

about const, this is for the base directory, const.HOME_DIR, as style sheets are saved in a file and when a report is taken, these must be read from the hard disk.
The same mechanism as retaining the report options.

The only way not to use this in /gen is to require on initialization to pass the directory where the file must be read from. 
As a consequence something like /gen/plug/_style.py/StyleOption would need in it's initialization also a directory as extra parameter. Not very beautifull.

This can be avoided though if
1/init of stylesheetlist does not require directory
2/parse and save need a directory
3/all reports using stylesheetlist must call a parse with the directory where the config file is. So the same way as a filter option must be filled in the report. There is no need though to do it in the reports themself, it can be done in ReportOptions.OptionList as that always sets a style. So it  could be done in a _ReportOptions.py OptionListCollection, meaning that the OptionHandler takes care of setting the correct directory (it already does  self.filename=const.REPORT_OPTIONS)

Quite some work for a simple import const import ...
You said you had some time coming up. Can I do the move and you remove this const import then afterward? Or too much risk it doesn't happen then?

The Utils is needed for two conversion functions that can easily be moved as definitions in gen/plug/docgen/basedoc

FontScale must be moved to gen also. It might be better to implement this with pango and a layout though, instead of hard coded.

Benny