diff --git a/src/bindgen/ir/documentation.rs b/src/bindgen/ir/documentation.rs index 8d5fcb6..6822c0e 100644 --- a/src/bindgen/ir/documentation.rs +++ b/src/bindgen/ir/documentation.rs @@ -43,9 +43,14 @@ impl Source for Documentation { return; } + let end = match config.documentation_length { + DocumentationLength::Short => 1, + DocumentationLength::Full => self.doc_comment.len(), + }; + // Cython uses Python-style comments, so `documentation_style` is not relevant. if config.language == Language::Cython { - for line in &self.doc_comment { + for line in &self.doc_comment[..end] { write!(out, "#{}", line); out.new_line(); } @@ -76,11 +81,6 @@ impl Source for Documentation { _ => (), } - let end = match config.documentation_length { - DocumentationLength::Short => 1, - DocumentationLength::Full => self.doc_comment.len(), - }; - for line in &self.doc_comment[..end] { match style { DocumentationStyle::C => out.write(""), diff --git a/tests/expectations/doclength_short.pyx b/tests/expectations/doclength_short.pyx index 72bf956..ea2838e 100644 --- a/tests/expectations/doclength_short.pyx +++ b/tests/expectations/doclength_short.pyx @@ -7,14 +7,7 @@ cdef extern from *: cdef extern from *: # The root of all evil. - # - # But at least it contains some more documentation as someone would expect - # from a simple test case like this. Though, this shouldn't appear in the - # output. void root(); # A little above the root, and a lot more visible, with a run-on sentence - # to test going over the first line. - # - # Still not here, though. void trunk();