hugovk/pypistats

Support RST Format

Closed this issue · 5 comments

Related to #20

Can be embedded Sphinx docs as well.

will start this on 22:00 (GMT+2), i think.

Sure, take your time :)

I was thinking about how to apply RST in that pypi_stats_api method and I thought maybe it is a good idea to implement a Format class, move (refactor) various methods such as _filter, _sort, _total, _percent and tabulate (probably as a new name, which is render) inside that class in order to minimize the implementations of new formats by subclassing Format. To demonstrate a prototype, my idea is:

Format class and its possible implementations

It would make it easier to implement new formats on the fly. There are things to consider though, such as encapsulation of some properties (for example, response property is encapsulated in protected level but data property is exposed, but I haven't considered the methods).

What are your thoughts? Do you think it is a good idea?

Actually, what about only passing format into _tabulate method. By doing this, we won't overengineer and won't have breaking API change.

Sometimes I overcomplicate things. 😄

Yes, that sounds much simpler!