Re: [PATCH v9 12/13] docs: parser_yaml.py: add support for line numbers from the parser

Donald Hunter <[email protected]> Thu, 10 Jul 2025 15:25:20 +0100
Newsgroups dev.linux.lists.lkmm,dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <[email protected]>
Donald Hunter <[email protected]> writes:

>>              # Parse message with RSTParser
>> -            for i, line in enumerate(msg.split('\n')):
>> -                result.append(line, document.current_source, i)
>> +            lineoffset = 0;
>> +            for line in msg.split('\n'):
>> +                match = self.re_lineno.match(line)
>> +                if match:
>> +                    lineoffset = int(match.group(1))
>> +                    continue
>> +
>> +                result.append(line, document.current_source, lineoffset)
>
> I expect this would need to be source=document.current_source, offset=lineoffset

Ignore that. I see it's not kwargs. It's just the issue below.

>>              rst_parser = RSTParser()
>>              rst_parser.parse('\n'.join(result), document)
>
> But anyway this discards any line information by just concatenating the
> lines together again.

Looks to me like there's no Parser() API that works with ViewList() so
it would be necessary to directly use the docutils RSTStateMachine() for
this approach to work.