From a1694cd57c604280efbe7a3ec0c3cb226680ba91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 2 Nov 2021 11:31:30 +0100 Subject: [PATCH] ir: Honor documentation_length in Cython. --- src/bindgen/ir/documentation.rs | 12 ++++++------ tests/expectations/doclength_short.pyx | 7 ------- 2 files changed, 6 insertions(+), 13 deletions(-) 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();