openSUSE / suse-doc-style-checker

Style Checker for SUSE Documentation
Other
2 stars 5 forks source link

Modularize code #116

Closed tomschr closed 7 years ago

tomschr commented 7 years ago

This is another PR is an attempt to split the bulky sdsc.py file into smaller parts. Futhermore, it tries to eliminate global definitions (partly).

It is not completely finished yet; there are some tricky parts which I'm not sure how to solve it.

Related issues are #10, #14 and #15.

@sknorr Let me know what do you think about my attempt... :)

tomschr commented 7 years ago

@sknorr In commit caf36ec and 843ef46 I've tried a "proof of concept" which I wanted to show to you.

The idea is to collect all XPath extension functions into a class and pass it to etree.XSLT(). The "extension mechanism" can be both accessed by XPath itself and in XSLT stylesheets.

The main part is the class MyXPathExtFunc. The constructor (__init__) expects a dictionary which is saved in each instance. This dictionary (self.arg) can be accessed by every extension function. ATM, the class just get a name: 'Tux'/'Wilber' entry; but it can be passed anything we need.

Another step in reducing these stinkin' globals... ;-)

ghost commented 7 years ago

Toms, I have pushed a few commits from this branch to develop, but none of the actual modularization commits. I have reused:

Since this branch can not be merged right now & this PR has been open for so long... I will close this PR for the moment. At this point, it is probably better to start modularizing from a fresh branch anyway.