Coder Social home page Coder Social logo

Comments (12)

aomader avatar aomader commented on September 21, 2024 2

@kernc If you give me some pointers I'll happily write up a PR.

from pdoc.

aomader avatar aomader commented on September 21, 2024

+1

from pdoc.

kernc avatar kernc commented on September 21, 2024

Which README.md would that be, the one in the same directory as __init__.py or one upper?

Only README.md or also readme.md, README.txt, README.rst?

from pdoc.

kernc avatar kernc commented on September 21, 2024

The way it would yield the most is with reST .. include:: directive.

How do you feel about that?

from pdoc.

kernc avatar kernc commented on September 21, 2024

If anyone would have a stab at that, the code is here.
There's already an exception for .. image:: and .. figure::.

pdoc/pdoc/html_helpers.py

Lines 189 to 215 in e2739ce

def _admonition(match):
indent, type, value, text = match.groups()
if type in ('image', 'figure'):
return '{}![{}]({})\n'.format(
indent, text.translate(str.maketrans({'\n': ' ',
'[': '\\[',
']': '\\]'})).strip(), value)
if type == 'versionchanged':
title = 'Changed in version: ' + value
elif type == 'versionadded':
title = 'Added in version: ' + value
elif type == 'deprecated' and value:
title = 'Deprecated since version: ' + value
elif type == 'admonition':
title = value
elif type.lower() == 'todo':
title = 'TODO'
text = value + ' ' + text
else:
title = type.capitalize()
if value:
title += ': ' + value
text = '\n'.join(indent + ' ' + line
for line in inspect.cleandoc(text).split('\n'))
return '{}!!! {} "{}"\n{}\n'.format(indent, type, title, text)

from pdoc.

wq2012 avatar wq2012 commented on September 21, 2024

From the user's perspective, I was thinking of using it like:

pdoc mymodule --html --inject-markdown-to-index=/PATH/TO/MY/README.md

from pdoc.

kernc avatar kernc commented on September 21, 2024

I think that's too ambiguous. Every package with __init__.py has an index. Which index?

Then, you can't control whether the injection is appended to or replaces the existing docstring.

Do you particularly dislike the .. include:: approach?

from pdoc.

aomader avatar aomader commented on September 21, 2024

I'm in favor of the .. include:: approach. Seems easy enough while allowing a lot more flexibility.

On a different page, what is rendered as index when I make pdoc build multiple modules?

from pdoc.

wq2012 avatar wq2012 commented on September 21, 2024

.. include:: is definitely good! Flexibility is great.

I was just mentioning an alternative user interface in my previous comment.

from pdoc.

kernc avatar kernc commented on September 21, 2024

from pdoc.

kernc avatar kernc commented on September 21, 2024
  • Make another admonition type exception for 'include' (probably call another function if more than a couple of lines).
    • Open up a file, read and return its contents but with each line preceded by indent.
      • If the file doesn't exist, re-raise a more descriptive exception.
    • Relative paths should probably be relative to the include statement appearance. You will need to pass module to _ToMarkdown.admonitions() to be able to handle relative includes.
    • I don't think you need to worry about directive options (:start-line:, :end-line:, ...) that you would find in text. Unless you find them trivial to implement, I'm completely happy if we don't support them or maybe add them later on an as-needed basis.
  • Add a documentation subsection "Supported reST directives", describing in brief what directives are supported and how.

from pdoc.

aomader avatar aomader commented on September 21, 2024

I wrote up everything as described (including the start end stuff) in PR #16 .

from pdoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.