nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.58k stars 1.47k forks source link

GitLab support for the docgen git.url #16642

Open artemklevtsov opened 3 years ago

artemklevtsov commented 3 years ago

Now docgen support only GitHub. It would be nice to add others.

timotheecour commented 3 years ago

Now docgen support only GitHub.

what do you mean? does --git.url:https://gitlab.com/myusername/myproject not work?

artemklevtsov commented 3 years ago

Template is https://{host}/{username}/{projname}/-/blob/{ref}/${filename}#L{numline}.

timotheecour commented 3 years ago

indeed,

PR welcome. it doesn't sound hard to fix.

doc.item.seesrc = """&nbsp;&nbsp;<a
href="${url}/tree/${commit}/${path}#L${line}"
class="link-seesrc" target="_blank">Source</a>

=>

doc.item.seesrc = """&nbsp;&nbsp;<a
href="${urlModif}/tree/${commit}/${path}#L${line}"
class="link-seesrc" target="_blank">Source</a>

and then in docgen.nim:

      dispA(d.conf, result, "$1", "", [ropeFormatNamedVars(d.conf, docItemSeeSrc,
          ["path", "line", "url", "commit", "devel"], [rope path.string,
          rope($line), rope gitUrl, rope commit, rope develBranch])])

compute urlModif from url depending on whether host is gitlab or github or other

artemklevtsov commented 3 years ago

I dived a bit into the documentation. Seems it can be solved through the configuration options. I put the following to the nimdoc.cfg in project root directory:

git.url = "https://gitlab.com/username/projectname"
git.commit = "master"
doc.item.seesrc = """&nbsp;&nbsp;<a href="${url}/-/blob/${commit}/${path}#L${line}" class="link-seesrc" target="_blank">Source</a>
<a href="${url}/-/edit/${commit}/${path}#L${line}" class="link-seesrc" target="_blank" >Edit</a>
"""
timotheecour commented 3 years ago

ya but it's better to make it work without user having to change config/nimdoc.cfg; --git.url should just work whether it's github or gitlab; something along the lines of https://github.com/nim-lang/Nim/issues/16642#issuecomment-757356276 should work