NiklasRosenstein / pydoc-markdown

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

(WIP) feat: ⚡️ Add `serverURL` & `serverPort` options (for Hugo Server) #202

Closed melMass closed 2 years ago

melMass commented 3 years ago

Hi,

I wanted a way to use a LAN server instead of localhost, but it does not seem easily doable with configurations only. I did not find lots of info on the matter on Hugo's forums but it seems others are having the same issue.

This PR almost works, by settings serverURL to 0.0.0.0 (outside localhost) & serverPort to 8080 (an open port on my router) I can access the doc from anywhere on the local network.

The only issue is that all the links are pointing to localhost... But replacing localhost with the machine's IP does work. I tried to set the IP as baseURL as advised in a Hugo issue but that did not work with pydoc markdown.

Tell me if there is an interest in making it part of the library.

NiklasRosenstein commented 3 years ago

I tried to set the IP as baseURL as advised in a Hugo issue but that did not work with pydoc markdown.

Hm this is weird, I would definitely expect that to work. 🤔 Do the URLs in the generated HTML not respect the baseURL at all?

NiklasRosenstein commented 3 years ago

Btw. I just merged #204 so you will need to merge and resolve conflicts, sorry about that 😄

melMass commented 3 years ago

Btw. I just merged #204 so you will need to merge and resolve conflicts, sorry about that 😄

No problem, I'm checking the image parsing first and I'll go back to this one. I need to test this in Hugo only first to understand how it's handled there.

Do the URLs in the generated HTML not respect the baseURL at all?

I will check this as well as I might have omitted the http:// part (not sure yet): I think this was my config

baseURL: "0.0.0.0"
serverURL: "0.0.0.0"

I'm checking the other issue using a Processor and your notes now

melMass commented 3 years ago

I'm asking here because I have yet to create the dedicated PR, but what steps should be taken to add a processor?

For now I called the processor images defined it in pydoc_markdown.contrib.processors.images:ImagesProcessor.

I added it to both the setup.py's pydoc_markdown.interfaces.Processor as

images = pydoc_markdown.contrib.processors.images:ImagesProcessor

and the PydocMarkdown.processors's default_factory.

For now, I just print in all interfaces to understand the flow of it all, but when I add it to my config I have the ModuleNotFoundError: No module named 'images'

NiklasRosenstein commented 3 years ago

Hey @melMass , Discussion would be the right place for this kind of question.😃 Would you mind opening a topic and we can discuss the image processor topic there?

melMass commented 3 years ago

Hey @melMass , Discussion would be the right place for this kind of question.😃 Would you mind opening a topic and we can discuss the image processor topic there?

Definitely, I forgot about discussions!

Heiss commented 2 years ago

Hey,

i want this feature, because i work in WSL2 and the default values are not usable in my setup. So it would be super handy to define the baseurl and port. What needs to be done to get an approval? How can i help you?

I would need this feature asap, because my current workaround is ugly: clone the fork of @melMass into my venv and copy my gitlab PR into it. :) This is not a good solution to publish, because pydoc-markdown changes the dir structure. Edit: As a better workaround and easier access for me, i implemented @melMass changes in a branch of a fork of mine (https://github.com/Heiss/pydoc-markdown/tree/server_url_option).

Thank you.

NiklasRosenstein commented 2 years ago

Hi @Heiss ,

I've opened a new PR https://github.com/NiklasRosenstein/pydoc-markdown/pull/231 for @melMass 's changes because I don't have permission to push to their fork; to address the nits. :)

I'll look to merge it and publish a new version soon.

Closing this in favor of #231.