Nbdev and Gitlab (source links)

Hi,

first of all thanks for this great library, nbdev is a great tool.

I am using it with gitlab and so far it works great. I have set up the CI-pipeline to create the docs and publish them on gitlab pages – I am happy to share my experience If anyone is interested.

However, the only thing I am currently struggeling with are the source-links in the documentation. There is a very small difference between the urls that are created by nbdev and the urls working in gitlab:

nbdev: https://gitlab.com/<repo>/projects/<project>/blob/main/<code>/code.py`
gitlab: https://gitlab.com/<repo>/projects/<project>/-/blob/main/<project>/code.py`

so because of this difference (the additional /-/ in the link), the source links in the documentation are failing.

I think i have found the place in the nbdev source where the links are created.

Does anyone have any ideas or suggestions on how to solve this problem? I thought about a small script changing the links in a post processing step, but maybe there is a better way?

Thanks

i have no solution to your problem, but i’m sure several people would be happy to read your experiences on using nbdev with gitlab in a blog post or here…

interested as well.
Have to use gitlab at work, and would like to publish to our artifactory using gitlab

Hi @tom_500 ,
The doclinks file is already importing the nbdev.config so one could access the host from the settings.ini with nbdev.config.get_config().

I don’t think it is the most elegant way, but probably this could work:

if get_config().get('host') == 'gitlab' :
    gh = urljoin( <gitlab-path>)
else:
    gh = urljoin( <github-path>)

I don’t know if I should open a new discussion for this, but did anybody here manage to deploy their project in gitlab pages ?
I don’t know if there is something that we should change in the .gitlab-cy.yml or it all comes from the nbdev_deploy script.

Feel free to use this issue to add specific things that are needed to better support Gitlab:

Ok, maybe I find a nice solution :slight_smile: will post it there, thanks

hi @pabloms92, @guillaumeramelet, @michaelaye I posted an example here, maybe this helps

4 Likes