pycco-docs / pycco

Literate-style documentation generator.

Home Page:https://pycco-docs.github.io/pycco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple code blocks require extra indentation

sanand0 opened this issue · comments

When I parse this docstring

"""
This is the first code sample

    alpha

This is the second code sample

    gamma
"""

... I get the following format:

This is the first code sample

alpha

This is the second code sample

gamma

But if I indent the second code block further, like this:

"""
This is the first code sample

    alpha

This is the second code sample

        gamma
"""

... I get the desired output:

This is the first code sample

alpha

This is the second code sample

gamma

The problem vanishes if https://github.com/fitzgen/pycco/blob/master/pycco/main.py#L128 is changed from

last_scope = current_scope if current_scope > last_scope else last_scope

... to ...

last_scope = current_scope

Is this a valid change? Or would it break something?

Regards
Anand

I haven't noticed a problem like this yet. I'm not familiar with that line, but I'll add it to my list of things to check if no one else gets to it first.

I'd probably use svn blame (or blame on Github) to trace that line back and see where the problem arose.

The earliest spot I can locate it at is
https://github.com/fitzgen/pycco/blob/71f9d5ab4e29d431e42efaa5994e8fb3e31513ec/pycco/main.py#L115

On Tue, Oct 4, 2011 at 3:51 PM, Trey Hunner <
reply@reply.github.com>wrote:

I haven't noticed a problem like this yet. I'm not familiar with that
line, but I'll add it to my list of things to check.

I'd probably use svn blame (or blame on Github) to trace that line back
and see where the problem arose.

Reply to this email directly or view it on GitHub:
#43 (comment)

It seems like that section of code can be simplified. I think a variable could be used to hold the number of spaces that the line is indented and that many spaces can be subtracted from the beginning of each line of the multi-line comment.

The markdown parser already handles formatting, so I'm not sure why code formatting is handled in that block as well.

I'll work on some sample code to replace that section. I need to find some code samples to test this on.

I haven't merged this into the master branch yet, but this simplification seems to work at least on your basic case: 3de4193 (in this branch).

I'll merge this into master once I've decided that this solution is less buggy than the previous.

Thanks, Trey. I'll try this out and let you know how it worked on my docs.

Regards
Anand

On Fri, Oct 7, 2011 at 4:07 PM, Trey Hunner <
reply@reply.github.com>wrote:

I haven't merged this into the master branch yet, but this simplification
seems to work at least on your basic case:
3de4193 (in this branch).

I'll merge this into master once I've decided that this solution is less
buggy than the previous.

Reply to this email directly or view it on GitHub:
#43 (comment)

Hi Trey,

This seems to work quite well in the few cases I've tried so far. Will look
forward to you merging it once you're comfortable.

Regards
Anand

On Fri, Oct 7, 2011 at 4:07 PM, Trey Hunner <
reply@reply.github.com>wrote:

I haven't merged this into the master branch yet, but this simplification
seems to work at least on your basic case:
3de4193 (in this branch).

I'll merge this into master once I've decided that this solution is less
buggy than the previous.

Reply to this email directly or view it on GitHub:
#43 (comment)

Great. Just merged it.