Skip to content

RDoc parses .c file as ruby code if markup is set to markdown in the first 3 lines #1597

@tompng

Description

@tompng

This file is parsed as ruby.

/* file.c */
/* :markup: markdown */
/* ↑ deleting the above line will make this file parsed as c */

#include <stdio.h>

#define def void
def foobar() {
}

/* method comment */
VALUE rb_a_foo(VALUE self) {
}

int main(){
  /* class comment */
  klass = rb_define_class("A", rb_cObject);
  rb_define_method(klass, "f", rb_a_foo, 0);
}

rdoc/lib/rdoc/parser.rb

Lines 233 to 238 in 5b15418

markup = content.lines.first(3).grep(/markup:\s+(\w+)/) { $1 }.first
return unless markup
# TODO Ruby should be returned only when the filename is correct
return RDoc::Parser::Ruby if %w[tomdoc markdown].include? markup

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions