NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
458 stars 102 forks source link

Add gitea source_linker #158

Closed tboulogne closed 3 years ago

tboulogne commented 3 years ago

Hello,

Here a PR to add gitea source_linker. Github is not the only one :-).

Regards

NiklasRosenstein commented 3 years ago

Hey @tboulogne , thanks for the contribution 👍

A few comments:

tboulogne commented 3 years ago

Hey @NiklasRosenstein,

let me check this an back to you :-)

tboulogne commented 3 years ago

@NiklasRosenstein hello, check it now please.

Regards

NiklasRosenstein commented 3 years ago

Hey @tboulogne ,

Thanks for looking into it!

I did actually like the split into two different classes (GithubSourceLinker and GiteaSourceLinker) because I would prefer to write

type: gitea
repo: me/repo

as opposed to

type: github
flavor: gitea
host: gitea.com
repo: me/repo

I was suggesting that we create a BaseGitSourceLinker that implements the generic logic of retrieving the SHA and constructing the URL, and then only override the URL_TEMPLATE in the subclass. 🙂 Something along the lines of

class GiteaSourceLinker(BaseGitSourceLinker):
  host = Field(str, default='gitea.com')  # Override the field from BaseGitSourceLinker with a different default
  URL_TEMPLATE =  'https://{host}/{repo}/src/commit/{sha}/{path}#L{lineno}'

Sorry for not being clear enough! I can also make this change later if you don't get to it / want to do it

Cheers

tboulogne commented 3 years ago

@NiklasRosenstein no problem ;-)

i will look into this week :-) and back to you.

tboulogne commented 3 years ago

@NiklasRosenstein let me know if it's ok for you :-)

tboulogne commented 3 years ago

@NiklasRosenstein done.

Your mods are far away what you explains here https://github.com/NiklasRosenstein/pydoc-markdown/pull/158#issuecomment-717277180 ...

NiklasRosenstein commented 3 years ago

Well originally in my mind it was a bit simpler to implement than what it turned out to be 😁

tboulogne commented 3 years ago

@NiklasRosenstein definitely :-)