cbindgen/bindgen/ir/
documentation.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5use crate::bindgen::utilities::SynAttributeHelpers;
6
7#[derive(Debug, Clone)]
8pub struct Documentation {
9    pub doc_comment: Vec<String>,
10}
11
12impl Documentation {
13    pub fn load(attrs: &[syn::Attribute]) -> Self {
14        let doc = attrs
15            .get_comment_lines()
16            .into_iter()
17            .filter(|x| !x.trim_start().starts_with("cbindgen:"))
18            .collect();
19
20        Documentation { doc_comment: doc }
21    }
22
23    pub fn simple(line: &str) -> Self {
24        Documentation {
25            doc_comment: vec![line.to_owned()],
26        }
27    }
28
29    pub fn none() -> Self {
30        Documentation {
31            doc_comment: Vec::new(),
32        }
33    }
34}