doxygen-rs-0.4.2/.cargo_vcs_info.json0000644000000001360000000000100131360ustar { "git": { "sha1": "311cb3121528347dfb3b03a5f7a6470ee5ca08ae" }, "path_in_vcs": "" }doxygen-rs-0.4.2/.github/workflows/rustdoc.yml000064400000000000000000000014350072674642500175640ustar 00000000000000name: rustdoc on: push: branches: - main jobs: rustdoc: if: github.repository == 'Techie-Pi/doxygen-rs' runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable profile: minimal override: true components: rustfmt, rust-src - name: Build Documentation run: cargo doc --all --no-deps - name: Deploy Docs uses: peaceiris/actions-gh-pages@364c31d33bb99327c77b3a5438a83a357a6729ad # v3.4.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: gh-pages publish_dir: ./target/doc force_orphan: truedoxygen-rs-0.4.2/.github/workflows/test.yml000064400000000000000000000004400072674642500170530ustar 00000000000000name: Test on: [push, pull_request] jobs: build_and_test: name: Test project runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: nightly - run: cargo test --verbose -- --show-outputdoxygen-rs-0.4.2/.gitignore000064400000000000000000000006320072674642500137470ustar 00000000000000# Generated by Cargo # will have compiled files and executables /target/ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk .idea/ assets/tests/bindgen-transformed.rs assets/tests/ctru-sys-bindings-transformed.rsdoxygen-rs-0.4.2/CHANGELOG.md000064400000000000000000000012100072674642500135610ustar 00000000000000# Changelog ## Version 0.4.2 - Improve group parsing - Trim strings where required ([rust3ds/ctru-rs#125](https://github.com/rust3ds/ctru-rs/pull/125#issuecomment-1568644343)) ## Version 0.4.1 - Fix missing parentheses in text ([#7](https://github.com/Techie-Pi/doxygen-rs/pull/7)) ## Version 0.4.0 - Rewrote _all_ the internals to improve speed and developer experience. - Only exposes the `doxygen_rs::transform` function and the `doxygen_rs::generator::rustdoc` function. ## Version 0.3.0 - Improve support for sublists and multiline strings [#5](https://github.com/Techie-Pi/doxygen-rs/pull/5) - Improve documentationdoxygen-rs-0.4.2/Cargo.toml0000644000000015240000000000100111360ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "doxygen-rs" version = "0.4.2" description = "Transform Doxygen to Rustdoc" homepage = "https://github.com/Techie-Pi/doxygen-rs/" readme = "README.md" keywords = [ "bindgen", "doxygen", "rustdoc", ] license = "BSD-3-Clause" repository = "https://github.com/Techie-Pi/doxygen-rs/" [dependencies.phf] version = "0.11" features = ["macros"] doxygen-rs-0.4.2/Cargo.toml.orig000064400000000000000000000005710072674642500146500ustar 00000000000000[package] name = "doxygen-rs" description = "Transform Doxygen to Rustdoc" homepage = "https://github.com/Techie-Pi/doxygen-rs/" repository = "https://github.com/Techie-Pi/doxygen-rs/" keywords = ["bindgen", "doxygen", "rustdoc"] readme = "README.md" license = "BSD-3-Clause" version = "0.4.2" edition = "2021" [dependencies] phf = { version = "0.11", features = ["macros"] } doxygen-rs-0.4.2/LICENSE000064400000000000000000000027540072674642500127730ustar 00000000000000BSD 3-Clause License Copyright (c) 2022, TechiePi All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. doxygen-rs-0.4.2/README.md000064400000000000000000000012040072674642500132320ustar 00000000000000# doxygen-rs Transform Doxygen to Rustdoc. [**Docs available here**](https://docs.rs/doxygen-rs/latest/doxygen_rs/) ## Installation Add this to your ``Cargo.toml`` ```toml [dependencies] doxygen-rs = "0.4" ``` ## Usage with Bindgen > Available on >=0.63 bindgen ```rs #[derive(Debug)] struct Cb; impl ParseCallbacks for Cb { fn process_comment(&self, comment: &str) -> Option { Some(doxygen_rs::transform(comment)) } } ``` ## Example ```rust use doxygen_rs::transform; let rustdoc = transform("@brief Example Doxygen brief"); assert_eq!(rustdoc, "Example Doxygen brief\n\n"); ``` doxygen-rs-0.4.2/src/emojis.rs000064400000000000000000000544530072674642500144140ustar 00000000000000use phf::phf_map; // Source: https://gist.github.com/rxaviers/7360908 from https://doxygen.nl/manual/commands.html#cmdemoji pub(crate) static EMOJIS: phf::Map<&'static str, &'static str> = phf_map! { "smile" => "๐Ÿ˜„", "laughing" => "๐Ÿ˜†", "blush" => "๐Ÿ˜Š", "smiley" => "๐Ÿ˜ƒ", "relaxed" => "โ˜บ๏ธ", "smirk" => "๐Ÿ˜", "heart_eyes" => "๐Ÿ˜", "kissing_heart" => "๐Ÿ˜˜", "kissing_closed_eyes" => "๐Ÿ˜š", "flushed" => "๐Ÿ˜ณ", "relieved" => "๐Ÿ˜Œ", "grin" => "๐Ÿ˜", "wink" => "๐Ÿ˜‰", "stuck_out_tongue_winking_eye" => "๐Ÿ˜œ", "stuck_out_tongue_closed_eyes" => "๐Ÿ˜", "grinning" => "๐Ÿ˜€", "kissing" => "๐Ÿ˜—", "kissing_smiling_eyes" => "๐Ÿ˜™", "stuck_out_tongue" => "๐Ÿ˜›", "sleeping" => "๐Ÿ˜ด", "worried" => "๐Ÿ˜Ÿ", "frowning" => "๐Ÿ˜ฆ", "anguished" => "๐Ÿ˜ง", "open_mouth" => "๐Ÿ˜ฎ", "grimacing" => "๐Ÿ˜ฌ", "confused" => "๐Ÿ˜•", "hushed" => "๐Ÿ˜ฏ", "expressionless" => "๐Ÿ˜‘", "unamused" => "๐Ÿ˜’", "sweat_smile" => "๐Ÿ˜…", "sweat" => "๐Ÿ˜“", "disappointed_relieved" => "๐Ÿ˜ฅ", "weary" => "๐Ÿ˜ฉ", "pensive" => "๐Ÿ˜”", "disappointed" => "๐Ÿ˜ž", "confounded" => "๐Ÿ˜–", "fearful" => "๐Ÿ˜จ", "cold_sweat" => "๐Ÿ˜ฐ", "persevere" => "๐Ÿ˜ฃ", "cry" => "๐Ÿ˜ข", "sob" => "๐Ÿ˜ญ", "joy" => "๐Ÿ˜‚", "astonished" => "๐Ÿ˜ฒ", "scream" => "๐Ÿ˜ฑ", "tired_face" => "๐Ÿ˜ซ", "angry" => "๐Ÿ˜ ", "rage" => "๐Ÿ˜ก", "triumph" => "๐Ÿ˜ค", "sleepy" => "๐Ÿ˜ช", "yum" => "๐Ÿ˜‹", "mask" => "๐Ÿ˜ท", "sunglasses" => "๐Ÿ˜Ž", "dizzy_face" => "๐Ÿ˜ต", "imp" => "๐Ÿ‘ฟ", "smiling_imp" => "๐Ÿ˜ˆ", "neutral_face" => "๐Ÿ˜", "no_mouth" => "๐Ÿ˜ถ", "innocent" => "๐Ÿ˜‡", "alien" => "๐Ÿ‘ฝ", "yellow_heart" => "๐Ÿ’›", "blue_heart" => "๐Ÿ’™", "purple_heart" => "๐Ÿ’œ", "heart" => "โค๏ธ", "green_heart" => "๐Ÿ’š", "broken_heart" => "๐Ÿ’”", "heartbeat" => "๐Ÿ’“", "heartpulse" => "๐Ÿ’—", "two_hearts" => "๐Ÿ’•", "revolving_hearts" => "๐Ÿ’ž", "cupid" => "๐Ÿ’˜", "sparkling_heart" => "๐Ÿ’–", "sparkles" => "โœจ", "star" => "โญ", "star2" => "๐ŸŒŸ", "dizzy" => "๐Ÿ’ซ", "boom" => "๐Ÿ’ฅ", "anger" => "๐Ÿ’ข", "exclamation" => "โ—", "question" => "โ“", "grey_exclamation" => "โ•", "grey_question" => "โ”", "zzz" => "๐Ÿ’ค", "dash" => "๐Ÿ’จ", "sweat_drops" => "๐Ÿ’ฆ", "notes" => "๐ŸŽถ", "musical_note" => "๐ŸŽต", "fire" => "๐Ÿ”ฅ", "hankey" => "๐Ÿ’ฉ", "+1" => "๐Ÿ‘", "-1" => "๐Ÿ‘Ž", "ok_hand" => "๐Ÿ‘Œ", "fist_oncoming" => "๐Ÿ‘Š", "fist_raised" => "โœŠ", "v" => "โœŒ๏ธ", "wave" => "๐Ÿ‘‹", "hand" => "โœ‹", "open_hands" => "๐Ÿ‘", "point_up" => "โ˜๏ธ", "point_down" => "๐Ÿ‘‡", "point_left" => "๐Ÿ‘ˆ", "point_right" => "๐Ÿ‘‰", "raised_hands" => "๐Ÿ™Œ", "pray" => "๐Ÿ™", "point_up_2" => "๐Ÿ‘†", "clap" => "๐Ÿ‘", "muscle" => "๐Ÿ’ช", "metal" => "๐Ÿค˜", "middle_finger" => "๐Ÿ–•", "walking" => "๐Ÿšถ", "runner" => "๐Ÿƒ", "couple" => "๐Ÿ‘ซ", "family" => "๐Ÿ‘ช", "two_men_holding_hands" => "๐Ÿ‘ฌ", "two_women_holding_hands" => "๐Ÿ‘ญ", "woman_dancing" => "๐Ÿ’ƒ", "dancers" => "๐Ÿ‘ฏ", "ok_woman" => "๐Ÿ™†โ€โ™€๏ธ", "no_good" => "๐Ÿ™…", "tipping_hand_person" => "๐Ÿ’", "raising_hand" => "๐Ÿ™‹", "woman_with_veil" => "๐Ÿ‘ฐโ€โ™€๏ธ", "bow" => "๐Ÿ™‡", "couplekiss" => "๐Ÿ’", "couple_with_heart" => "๐Ÿ’‘", "massage" => "๐Ÿ’†", "haircut" => "๐Ÿ’‡", "nail_care" => "๐Ÿ’…", "boy" => "๐Ÿ‘ฆ", "girl" => "๐Ÿ‘ง", "woman" => "๐Ÿ‘ฉ", "man" => "๐Ÿ‘จ", "baby" => "๐Ÿ‘ถ", "older_woman" => "๐Ÿ‘ต", "older_man" => "๐Ÿ‘ด", "man_with_gua_pi_mao" => "๐Ÿ‘ฒ", "man_with_turban" => "๐Ÿ‘ณโ€โ™‚๏ธ", "construction_worker" => "๐Ÿ‘ท", "police_officer" => "๐Ÿ‘ฎ", "angel" => "๐Ÿ‘ผ", "princess" => "๐Ÿ‘ธ", "smiley_cat" => "๐Ÿ˜บ", "smile_cat" => "๐Ÿ˜ธ", "heart_eyes_cat" => "๐Ÿ˜ป", "kissing_cat" => "๐Ÿ˜ฝ", "smirk_cat" => "๐Ÿ˜ผ", "scream_cat" => "๐Ÿ™€", "crying_cat_face" => "๐Ÿ˜ฟ", "joy_cat" => "๐Ÿ˜น", "pouting_cat" => "๐Ÿ˜พ", "japanese_ogre" => "๐Ÿ‘น", "japanese_goblin" => "๐Ÿ‘บ", "see_no_evil" => "๐Ÿ™ˆ", "hear_no_evil" => "๐Ÿ™‰", "speak_no_evil" => "๐Ÿ™Š", "guardsman" => "๐Ÿ’‚โ€โ™‚๏ธ", "skull" => "๐Ÿ’€", "feet" => "๐Ÿพ", "lips" => "๐Ÿ‘„", "kiss" => "๐Ÿ’‹", "droplet" => "๐Ÿ’ง", "ear" => "๐Ÿ‘‚", "eyes" => "๐Ÿ‘€", "nose" => "๐Ÿ‘ƒ", "tongue" => "๐Ÿ‘…", "love_letter" => "๐Ÿ’Œ", "bust_in_silhouette" => "๐Ÿ‘ค", "busts_in_silhouette" => "๐Ÿ‘ฅ", "speech_balloon" => "๐Ÿ’ฌ", "thought_balloon" => "๐Ÿ’ญ", "sunny" => "โ˜€๏ธ", "umbrella" => "โ˜”", "cloud" => "โ˜๏ธ", "snowflake" => "โ„๏ธ", "snowman" => "โ›„", "zap" => "โšก", "cyclone" => "๐ŸŒ€", "foggy" => "๐ŸŒ", "ocean" => "๐ŸŒŠ", "cat" => "๐Ÿฑ", "dog" => "๐Ÿถ", "mouse" => "๐Ÿญ", "hamster" => "๐Ÿน", "rabbit" => "๐Ÿฐ", "wolf" => "๐Ÿบ", "frog" => "๐Ÿธ", "tiger" => "๐Ÿฏ", "koala" => "๐Ÿจ", "bear" => "๐Ÿป", "pig" => "๐Ÿท", "pig_nose" => "๐Ÿฝ", "cow" => "๐Ÿฎ", "boar" => "๐Ÿ—", "monkey_face" => "๐Ÿต", "monkey" => "๐Ÿ’", "horse" => "๐Ÿด", "racehorse" => "๐ŸŽ", "camel" => "๐Ÿซ", "sheep" => "๐Ÿ‘", "elephant" => "๐Ÿ˜", "panda_face" => "๐Ÿผ", "snake" => "๐Ÿ", "bird" => "๐Ÿฆ", "baby_chick" => "๐Ÿค", "hatched_chick" => "๐Ÿฅ", "hatching_chick" => "๐Ÿฃ", "chicken" => "๐Ÿ”", "penguin" => "๐Ÿง", "turtle" => "๐Ÿข", "bug" => "๐Ÿ›", "bee" => "๐Ÿ", "ant" => "๐Ÿœ", "beetle" => "๐Ÿชฒ", "snail" => "๐ŸŒ", "octopus" => "๐Ÿ™", "tropical_fish" => "๐Ÿ ", "fish" => "๐ŸŸ", "whale" => "๐Ÿณ", "whale2" => "๐Ÿ‹", "dolphin" => "๐Ÿฌ", "cow2" => "๐Ÿ„", "ram" => "๐Ÿ", "rat" => "๐Ÿ€", "water_buffalo" => "๐Ÿƒ", "tiger2" => "๐Ÿ…", "rabbit2" => "๐Ÿ‡", "dragon" => "๐Ÿ‰", "goat" => "๐Ÿ", "rooster" => "๐Ÿ“", "dog2" => "๐Ÿ•", "pig2" => "๐Ÿ–", "mouse2" => "๐Ÿ", "ox" => "๐Ÿ‚", "dragon_face" => "๐Ÿฒ", "blowfish" => "๐Ÿก", "crocodile" => "๐ŸŠ", "dromedary_camel" => "๐Ÿช", "leopard" => "๐Ÿ†", "cat2" => "๐Ÿˆ", "poodle" => "๐Ÿฉ", "bouquet" => "๐Ÿ’", "cherry_blossom" => "๐ŸŒธ", "tulip" => "๐ŸŒท", "four_leaf_clover" => "๐Ÿ€", "rose" => "๐ŸŒน", "sunflower" => "๐ŸŒป", "hibiscus" => "๐ŸŒบ", "maple_leaf" => "๐Ÿ", "leaves" => "๐Ÿƒ", "fallen_leaf" => "๐Ÿ‚", "herb" => "๐ŸŒฟ", "mushroom" => "๐Ÿ„", "cactus" => "๐ŸŒต", "palm_tree" => "๐ŸŒด", "evergreen_tree" => "๐ŸŒฒ", "deciduous_tree" => "๐ŸŒณ", "chestnut" => "๐ŸŒฐ", "seedling" => "๐ŸŒฑ", "blossom" => "๐ŸŒผ", "ear_of_rice" => "๐ŸŒพ", "shell" => "๐Ÿš", "globe_with_meridians" => "๐ŸŒ", "sun_with_face" => "๐ŸŒž", "full_moon_with_face" => "๐ŸŒ", "new_moon_with_face" => "๐ŸŒš", "new_moon" => "๐ŸŒ‘", "waxing_crescent_moon" => "๐ŸŒ’", "first_quarter_moon" => "๐ŸŒ“", "moon" => "๐ŸŒ”", "full_moon" => "๐ŸŒ•", "waning_gibbous_moon" => "๐ŸŒ–", "last_quarter_moon" => "๐ŸŒ—", "waning_crescent_moon" => "๐ŸŒ˜", "last_quarter_moon_with_face" => "๐ŸŒœ", "first_quarter_moon_with_face" => "๐ŸŒ›", "earth_africa" => "๐ŸŒ", "earth_americas" => "๐ŸŒŽ", "earth_asia" => "๐ŸŒ", "volcano" => "๐ŸŒ‹", "milky_way" => "๐ŸŒŒ", "partly_sunny" => "โ›…", "bamboo" => "๐ŸŽ", "gift_heart" => "๐Ÿ’", "dolls" => "๐ŸŽŽ", "school_satchel" => "๐ŸŽ’", "mortar_board" => "๐ŸŽ“", "flags" => "๐ŸŽ", "fireworks" => "๐ŸŽ†", "sparkler" => "๐ŸŽ‡", "wind_chime" => "๐ŸŽ", "rice_scene" => "๐ŸŽ‘", "jack_o_lantern" => "๐ŸŽƒ", "ghost" => "๐Ÿ‘ป", "santa" => "๐ŸŽ…", "christmas_tree" => "๐ŸŽ„", "gift" => "๐ŸŽ", "bell" => "๐Ÿ””", "no_bell" => "๐Ÿ”•", "tanabata_tree" => "๐ŸŽ‹", "tada" => "๐ŸŽ‰", "confetti_ball" => "๐ŸŽŠ", "balloon" => "๐ŸŽˆ", "crystal_ball" => "๐Ÿ”ฎ", "cd" => "๐Ÿ’ฟ", "dvd" => "๐Ÿ“€", "floppy_disk" => "๐Ÿ’พ", "camera" => "๐Ÿ“ท", "video_camera" => "๐Ÿ“น", "movie_camera" => "๐ŸŽฅ", "computer" => "๐Ÿ’ป", "tv" => "๐Ÿ“บ", "iphone" => "๐Ÿ“ฑ", "phone" => "โ˜Ž๏ธ", "telephone_receiver" => "๐Ÿ“ž", "pager" => "๐Ÿ“Ÿ", "fax" => "๐Ÿ“ ", "minidisc" => "๐Ÿ’ฝ", "vhs" => "๐Ÿ“ผ", "sound" => "๐Ÿ”‰", "speaker" => "๐Ÿ”ˆ", "mute" => "๐Ÿ”‡", "loudspeaker" => "๐Ÿ“ข", "mega" => "๐Ÿ“ฃ", "hourglass" => "โŒ›", "hourglass_flowing_sand" => "โณ", "alarm_clock" => "โฐ", "watch" => "โŒš", "radio" => "๐Ÿ“ป", "satellite" => "๐Ÿ“ก", "loop" => "โžฟ", "mag" => "๐Ÿ”", "mag_right" => "๐Ÿ”Ž", "unlock" => "๐Ÿ”“", "lock" => "๐Ÿ”’", "lock_with_ink_pen" => "๐Ÿ”", "closed_lock_with_key" => "๐Ÿ”", "key" => "๐Ÿ”‘", "bulb" => "๐Ÿ’ก", "flashlight" => "๐Ÿ”ฆ", "high_brightness" => "๐Ÿ”†", "low_brightness" => "๐Ÿ”…", "electric_plug" => "๐Ÿ”Œ", "battery" => "๐Ÿ”‹", "calling" => "๐Ÿ“ฒ", "email" => "๐Ÿ“ง", "mailbox" => "๐Ÿ“ซ", "postbox" => "๐Ÿ“ฎ", "bath" => "๐Ÿ›€", "bathtub" => "๐Ÿ›", "shower" => "๐Ÿšฟ", "toilet" => "๐Ÿšฝ", "wrench" => "๐Ÿ”ง", "nut_and_bolt" => "๐Ÿ”ฉ", "hammer" => "๐Ÿ”จ", "seat" => "๐Ÿ’บ", "moneybag" => "๐Ÿ’ฐ", "yen" => "๐Ÿ’ด", "dollar" => "๐Ÿ’ต", "pound" => "๐Ÿ’ท", "euro" => "๐Ÿ’ถ", "credit_card" => "๐Ÿ’ณ", "money_with_wings" => "๐Ÿ’ธ", "inbox_tray" => "๐Ÿ“ฅ", "outbox_tray" => "๐Ÿ“ค", "envelope" => "โœ‰๏ธ", "incoming_envelope" => "๐Ÿ“จ", "postal_horn" => "๐Ÿ“ฏ", "mailbox_closed" => "๐Ÿ“ช", "mailbox_with_mail" => "๐Ÿ“ฌ", "mailbox_with_no_mail" => "๐Ÿ“ญ", "door" => "๐Ÿšช", "smoking" => "๐Ÿšฌ", "bomb" => "๐Ÿ’ฃ", "gun" => "๐Ÿ”ซ", "hocho" => "๐Ÿ”ช", "pill" => "๐Ÿ’Š", "syringe" => "๐Ÿ’‰", "page_facing_up" => "๐Ÿ“„", "page_with_curl" => "๐Ÿ“ƒ", "bookmark_tabs" => "๐Ÿ“‘", "bar_chart" => "๐Ÿ“Š", "chart_with_upwards_trend" => "๐Ÿ“ˆ", "chart_with_downwards_trend" => "๐Ÿ“‰", "scroll" => "๐Ÿ“œ", "clipboard" => "๐Ÿ“‹", "calendar" => "๐Ÿ“†", "date" => "๐Ÿ“…", "card_index" => "๐Ÿ“‡", "file_folder" => "๐Ÿ“", "open_file_folder" => "๐Ÿ“‚", "scissors" => "โœ‚๏ธ", "pushpin" => "๐Ÿ“Œ", "paperclip" => "๐Ÿ“Ž", "black_nib" => "โœ’๏ธ", "pencil2" => "โœ๏ธ", "straight_ruler" => "๐Ÿ“", "triangular_ruler" => "๐Ÿ“", "closed_book" => "๐Ÿ“•", "green_book" => "๐Ÿ“—", "blue_book" => "๐Ÿ“˜", "orange_book" => "๐Ÿ“™", "notebook" => "๐Ÿ““", "notebook_with_decorative_cover" => "๐Ÿ“”", "ledger" => "๐Ÿ“’", "books" => "๐Ÿ“š", "bookmark" => "๐Ÿ”–", "name_badge" => "๐Ÿ“›", "microscope" => "๐Ÿ”ฌ", "telescope" => "๐Ÿ”ญ", "newspaper" => "๐Ÿ“ฐ", "football" => "๐Ÿˆ", "basketball" => "๐Ÿ€", "soccer" => "โšฝ", "baseball" => "โšพ", "tennis" => "๐ŸŽพ", "8ball" => "๐ŸŽฑ", "rugby_football" => "๐Ÿ‰", "bowling" => "๐ŸŽณ", "golf" => "โ›ณ", "mountain_bicyclist" => "๐Ÿšต", "bicyclist" => "๐Ÿšด", "horse_racing" => "๐Ÿ‡", "snowboarder" => "๐Ÿ‚", "swimmer" => "๐ŸŠ", "surfer" => "๐Ÿ„", "ski" => "๐ŸŽฟ", "spades" => "โ™ ๏ธ", "hearts" => "โ™ฅ๏ธ", "clubs" => "โ™ฃ๏ธ", "diamonds" => "โ™ฆ๏ธ", "gem" => "๐Ÿ’Ž", "ring" => "๐Ÿ’", "trophy" => "๐Ÿ†", "musical_score" => "๐ŸŽผ", "musical_keyboard" => "๐ŸŽน", "violin" => "๐ŸŽป", "space_invader" => "๐Ÿ‘พ", "video_game" => "๐ŸŽฎ", "black_joker" => "๐Ÿƒ", "flower_playing_cards" => "๐ŸŽด", "game_die" => "๐ŸŽฒ", "dart" => "๐ŸŽฏ", "mahjong" => "๐Ÿ€„", "clapper" => "๐ŸŽฌ", "memo" => "๐Ÿ“", "book" => "๐Ÿ“–", "art" => "๐ŸŽจ", "microphone" => "๐ŸŽค", "headphones" => "๐ŸŽง", "trumpet" => "๐ŸŽบ", "saxophone" => "๐ŸŽท", "guitar" => "๐ŸŽธ", "mans_shoe" => "๐Ÿ‘ž", "sandal" => "๐Ÿ‘ก", "high_heel" => "๐Ÿ‘ ", "lipstick" => "๐Ÿ’„", "boot" => "๐Ÿ‘ข", "shirt" => "๐Ÿ‘•", "necktie" => "๐Ÿ‘”", "womans_clothes" => "๐Ÿ‘š", "dress" => "๐Ÿ‘—", "running_shirt_with_sash" => "๐ŸŽฝ", "jeans" => "๐Ÿ‘–", "kimono" => "๐Ÿ‘˜", "bikini" => "๐Ÿ‘™", "ribbon" => "๐ŸŽ€", "tophat" => "๐ŸŽฉ", "crown" => "๐Ÿ‘‘", "womans_hat" => "๐Ÿ‘’", "closed_umbrella" => "๐ŸŒ‚", "briefcase" => "๐Ÿ’ผ", "handbag" => "๐Ÿ‘œ", "pouch" => "๐Ÿ‘", "purse" => "๐Ÿ‘›", "eyeglasses" => "๐Ÿ‘“", "fishing_pole_and_fish" => "๐ŸŽฃ", "coffee" => "โ˜•", "tea" => "๐Ÿต", "sake" => "๐Ÿถ", "baby_bottle" => "๐Ÿผ", "beer" => "๐Ÿบ", "beers" => "๐Ÿป", "cocktail" => "๐Ÿธ", "tropical_drink" => "๐Ÿน", "wine_glass" => "๐Ÿท", "fork_and_knife" => "๐Ÿด", "pizza" => "๐Ÿ•", "hamburger" => "๐Ÿ”", "fries" => "๐ŸŸ", "poultry_leg" => "๐Ÿ—", "meat_on_bone" => "๐Ÿ–", "spaghetti" => "๐Ÿ", "curry" => "๐Ÿ›", "fried_shrimp" => "๐Ÿค", "bento" => "๐Ÿฑ", "sushi" => "๐Ÿฃ", "fish_cake" => "๐Ÿฅ", "rice_ball" => "๐Ÿ™", "rice_cracker" => "๐Ÿ˜", "rice" => "๐Ÿš", "ramen" => "๐Ÿœ", "stew" => "๐Ÿฒ", "oden" => "๐Ÿข", "dango" => "๐Ÿก", "egg" => "๐Ÿฅš", "bread" => "๐Ÿž", "doughnut" => "๐Ÿฉ", "custard" => "๐Ÿฎ", "icecream" => "๐Ÿฆ", "ice_cream" => "๐Ÿจ", "shaved_ice" => "๐Ÿง", "birthday" => "๐ŸŽ‚", "cake" => "๐Ÿฐ", "cookie" => "๐Ÿช", "chocolate_bar" => "๐Ÿซ", "candy" => "๐Ÿฌ", "lollipop" => "๐Ÿญ", "honey_pot" => "๐Ÿฏ", "apple" => "๐ŸŽ", "green_apple" => "๐Ÿ", "tangerine" => "๐ŸŠ", "lemon" => "๐Ÿ‹", "cherries" => "๐Ÿ’", "grapes" => "๐Ÿ‡", "watermelon" => "๐Ÿ‰", "strawberry" => "๐Ÿ“", "peach" => "๐Ÿ‘", "melon" => "๐Ÿˆ", "banana" => "๐ŸŒ", "pear" => "๐Ÿ", "pineapple" => "๐Ÿ", "sweet_potato" => "๐Ÿ ", "eggplant" => "๐Ÿ†", "tomato" => "๐Ÿ…", "corn" => "๐ŸŒฝ", "house" => "๐Ÿ ", "house_with_garden" => "๐Ÿก", "school" => "๐Ÿซ", "office" => "๐Ÿข", "post_office" => "๐Ÿฃ", "hospital" => "๐Ÿฅ", "bank" => "๐Ÿฆ", "convenience_store" => "๐Ÿช", "love_hotel" => "๐Ÿฉ", "hotel" => "๐Ÿจ", "wedding" => "๐Ÿ’’", "church" => "โ›ช", "department_store" => "๐Ÿฌ", "european_post_office" => "๐Ÿค", "city_sunrise" => "๐ŸŒ‡", "city_sunset" => "๐ŸŒ†", "japanese_castle" => "๐Ÿฏ", "european_castle" => "๐Ÿฐ", "tent" => "โ›บ", "factory" => "๐Ÿญ", "tokyo_tower" => "๐Ÿ—ผ", "japan" => "๐Ÿ—พ", "mount_fuji" => "๐Ÿ—ป", "sunrise_over_mountains" => "๐ŸŒ„", "sunrise" => "๐ŸŒ…", "stars" => "๐ŸŒ ", "statue_of_liberty" => "๐Ÿ—ฝ", "bridge_at_night" => "๐ŸŒ‰", "carousel_horse" => "๐ŸŽ ", "rainbow" => "๐ŸŒˆ", "ferris_wheel" => "๐ŸŽก", "fountain" => "โ›ฒ", "roller_coaster" => "๐ŸŽข", "ship" => "๐Ÿšข", "speedboat" => "๐Ÿšค", "boat" => "โ›ต", "rowboat" => "๐Ÿšฃ", "anchor" => "โš“", "rocket" => "๐Ÿš€", "airplane" => "โœˆ๏ธ", "helicopter" => "๐Ÿš", "steam_locomotive" => "๐Ÿš‚", "tram" => "๐ŸšŠ", "mountain_railway" => "๐Ÿšž", "bike" => "๐Ÿšฒ", "aerial_tramway" => "๐Ÿšก", "suspension_railway" => "๐ŸšŸ", "mountain_cableway" => "๐Ÿš ", "tractor" => "๐Ÿšœ", "blue_car" => "๐Ÿš™", "oncoming_automobile" => "๐Ÿš˜", "car" => "๐Ÿš—", "taxi" => "๐Ÿš•", "oncoming_taxi" => "๐Ÿš–", "articulated_lorry" => "๐Ÿš›", "bus" => "๐ŸšŒ", "oncoming_bus" => "๐Ÿš", "rotating_light" => "๐Ÿšจ", "police_car" => "๐Ÿš“", "oncoming_police_car" => "๐Ÿš”", "fire_engine" => "๐Ÿš’", "ambulance" => "๐Ÿš‘", "minibus" => "๐Ÿš", "truck" => "๐Ÿšš", "train" => "๐Ÿš‹", "station" => "๐Ÿš‰", "train2" => "๐Ÿš†", "bullettrain_front" => "๐Ÿš…", "bullettrain_side" => "๐Ÿš„", "light_rail" => "๐Ÿšˆ", "monorail" => "๐Ÿš", "railway_car" => "๐Ÿšƒ", "trolleybus" => "๐ŸšŽ", "ticket" => "๐ŸŽซ", "fuelpump" => "โ›ฝ", "vertical_traffic_light" => "๐Ÿšฆ", "traffic_light" => "๐Ÿšฅ", "warning" => "โš ๏ธ", "construction" => "๐Ÿšง", "beginner" => "๐Ÿ”ฐ", "atm" => "๐Ÿง", "slot_machine" => "๐ŸŽฐ", "busstop" => "๐Ÿš", "barber" => "๐Ÿ’ˆ", "hotsprings" => "โ™จ๏ธ", "checkered_flag" => "๐Ÿ", "crossed_flags" => "๐ŸŽŒ", "izakaya_lantern" => "๐Ÿฎ", "moyai" => "๐Ÿ—ฟ", "circus_tent" => "๐ŸŽช", "performing_arts" => "๐ŸŽญ", "round_pushpin" => "๐Ÿ“", "triangular_flag_on_post" => "๐Ÿšฉ", "jp" => "๐Ÿ‡ฏ๐Ÿ‡ต", "kr" => "๐Ÿ‡ฐ๐Ÿ‡ท", "cn" => "๐Ÿ‡จ๐Ÿ‡ณ", "us" => "๐Ÿ‡บ๐Ÿ‡ธ", "fr" => "๐Ÿ‡ซ๐Ÿ‡ท", "es" => "๐Ÿ‡ช๐Ÿ‡ธ", "it" => "๐Ÿ‡ฎ๐Ÿ‡น", "ru" => "๐Ÿ‡ท๐Ÿ‡บ", "gb" => "๐Ÿ‡ฌ๐Ÿ‡ง", "de" => "๐Ÿ‡ฉ๐Ÿ‡ช", "one" => "1๏ธโƒฃ", "two" => "2๏ธโƒฃ", "three" => "3๏ธโƒฃ", "four" => "4๏ธโƒฃ", "five" => "5๏ธโƒฃ", "six" => "6๏ธโƒฃ", "seven" => "7๏ธโƒฃ", "eight" => "8๏ธโƒฃ", "nine" => "9๏ธโƒฃ", "keycap_ten" => "๐Ÿ”Ÿ", "1234" => "๐Ÿ”ข", "zero" => "0๏ธโƒฃ", "hash" => "#๏ธโƒฃ", "symbols" => "๐Ÿ”ฃ", "arrow_backward" => "โ—€๏ธ", "arrow_down" => "โฌ‡๏ธ", "arrow_forward" => "โ–ถ๏ธ", "arrow_left" => "โฌ…๏ธ", "capital_abcd" => "๐Ÿ” ", "abcd" => "๐Ÿ”ก", "abc" => "๐Ÿ”ค", "arrow_lower_left" => "โ†™๏ธ", "arrow_lower_right" => "โ†˜๏ธ", "arrow_right" => "โžก๏ธ", "arrow_up" => "โฌ†๏ธ", "arrow_upper_left" => "โ†–๏ธ", "arrow_upper_right" => "โ†—๏ธ", "arrow_double_down" => "โฌ", "arrow_double_up" => "โซ", "arrow_down_small" => "๐Ÿ”ฝ", "arrow_heading_down" => "โคต๏ธ", "arrow_heading_up" => "โคด๏ธ", "leftwards_arrow_with_hook" => "โ†ฉ๏ธ", "arrow_right_hook" => "โ†ช๏ธ", "left_right_arrow" => "โ†”๏ธ", "arrow_up_down" => "โ†•๏ธ", "arrow_up_small" => "๐Ÿ”ผ", "arrows_clockwise" => "๐Ÿ”ƒ", "arrows_counterclockwise" => "๐Ÿ”„", "rewind" => "โช", "fast_forward" => "โฉ", "information_source" => "โ„น๏ธ", "ok" => "๐Ÿ†—", "twisted_rightwards_arrows" => "๐Ÿ”€", "repeat" => "๐Ÿ”", "repeat_one" => "๐Ÿ”‚", "new" => "๐Ÿ†•", "top" => "๐Ÿ”", "up" => "๐Ÿ†™", "cool" => "๐Ÿ†’", "free" => "๐Ÿ†“", "ng" => "๐Ÿ†–", "cinema" => "๐ŸŽฆ", "koko" => "๐Ÿˆ", "signal_strength" => "๐Ÿ“ถ", "u5272" => "๐Ÿˆน", "u5408" => "๐Ÿˆด", "u55b6" => "๐Ÿˆบ", "u6307" => "๐Ÿˆฏ", "u6708" => "๐Ÿˆท๏ธ", "u6709" => "๐Ÿˆถ", "u6e80" => "๐Ÿˆต", "u7121" => "๐Ÿˆš", "u7533" => "๐Ÿˆธ", "u7a7a" => "๐Ÿˆณ", "u7981" => "๐Ÿˆฒ", "sa" => "๐Ÿˆ‚๏ธ", "restroom" => "๐Ÿšป", "mens" => "๐Ÿšน", "womens" => "๐Ÿšบ", "baby_symbol" => "๐Ÿšผ", "no_smoking" => "๐Ÿšญ", "parking" => "๐Ÿ…ฟ๏ธ", "wheelchair" => "โ™ฟ", "metro" => "๐Ÿš‡", "baggage_claim" => "๐Ÿ›„", "accept" => "๐Ÿ‰‘", "wc" => "๐Ÿšพ", "potable_water" => "๐Ÿšฐ", "put_litter_in_its_place" => "๐Ÿšฎ", "secret" => "ใŠ™๏ธ", "congratulations" => "ใŠ—๏ธ", "m" => "โ“‚๏ธ", "passport_control" => "๐Ÿ›‚", "left_luggage" => "๐Ÿ›…", "customs" => "๐Ÿ›ƒ", "ideograph_advantage" => "๐Ÿ‰", "cl" => "๐Ÿ†‘", "sos" => "๐Ÿ†˜", "id" => "๐Ÿ†”", "no_entry_sign" => "๐Ÿšซ", "underage" => "๐Ÿ”ž", "no_mobile_phones" => "๐Ÿ“ต", "do_not_litter" => "๐Ÿšฏ", "non-potable_water" => "๐Ÿšฑ", "no_bicycles" => "๐Ÿšณ", "no_pedestrians" => "๐Ÿšท", "children_crossing" => "๐Ÿšธ", "no_entry" => "โ›”", "eight_spoked_asterisk" => "โœณ๏ธ", "eight_pointed_black_star" => "โœด๏ธ", "heart_decoration" => "๐Ÿ’Ÿ", "vs" => "๐Ÿ†š", "vibration_mode" => "๐Ÿ“ณ", "mobile_phone_off" => "๐Ÿ“ด", "chart" => "๐Ÿ’น", "currency_exchange" => "๐Ÿ’ฑ", "aries" => "โ™ˆ", "taurus" => "โ™‰", "gemini" => "โ™Š", "cancer" => "โ™‹", "leo" => "โ™Œ", "virgo" => "โ™", "libra" => "โ™Ž", "scorpius" => "โ™", "sagittarius" => "โ™", "capricorn" => "โ™‘", "aquarius" => "โ™’", "pisces" => "โ™“", "ophiuchus" => "โ›Ž", "six_pointed_star" => "๐Ÿ”ฏ", "negative_squared_cross_mark" => "โŽ", "a" => "๐Ÿ…ฐ๏ธ", "b" => "๐Ÿ…ฑ๏ธ", "ab" => "๐Ÿ†Ž", "o2" => "๐Ÿ…พ๏ธ", "diamond_shape_with_a_dot_inside" => "๐Ÿ’ ", "recycle" => "โ™ป๏ธ", "end" => "๐Ÿ”š", "on" => "๐Ÿ”›", "soon" => "๐Ÿ”œ", "clock1" => "๐Ÿ•", "clock130" => "๐Ÿ•œ", "clock10" => "๐Ÿ•™", "clock1030" => "๐Ÿ•ฅ", "clock11" => "๐Ÿ•š", "clock1130" => "๐Ÿ•ฆ", "clock12" => "๐Ÿ•›", "clock1230" => "๐Ÿ•ง", "clock2" => "๐Ÿ•‘", "clock230" => "๐Ÿ•", "clock3" => "๐Ÿ•’", "clock330" => "๐Ÿ•ž", "clock4" => "๐Ÿ•“", "clock430" => "๐Ÿ•Ÿ", "clock5" => "๐Ÿ•”", "clock530" => "๐Ÿ• ", "clock6" => "๐Ÿ••", "clock630" => "๐Ÿ•ก", "clock7" => "๐Ÿ•–", "clock730" => "๐Ÿ•ข", "clock8" => "๐Ÿ•—", "clock830" => "๐Ÿ•ฃ", "clock9" => "๐Ÿ•˜", "clock930" => "๐Ÿ•ค", "heavy_dollar_sign" => "๐Ÿ’ฒ", "copyright" => "ยฉ๏ธ", "registered" => "ยฎ๏ธ", "tm" => "โ„ข๏ธ", "x" => "โŒ", "bangbang" => "โ€ผ๏ธ", "interrobang" => "โ‰๏ธ", "o" => "โญ•", "heavy_multiplication_x" => "โœ–๏ธ", "heavy_plus_sign" => "โž•", "heavy_minus_sign" => "โž–", "heavy_division_sign" => "โž—", "white_flower" => "๐Ÿ’ฎ", "100" => "๐Ÿ’ฏ", "heavy_check_mark" => "โœ”๏ธ", "ballot_box_with_check" => "โ˜‘๏ธ", "radio_button" => "๐Ÿ”˜", "link" => "๐Ÿ”—", "curly_loop" => "โžฐ", "wavy_dash" => "ใ€ฐ๏ธ", "part_alternation_mark" => "ใ€ฝ๏ธ", "trident" => "๐Ÿ”ฑ", "white_check_mark" => "โœ…", "black_square_button" => "๐Ÿ”ฒ", "white_square_button" => "๐Ÿ”ณ", "black_circle" => "โšซ", "white_circle" => "โšช", "red_circle" => "๐Ÿ”ด", "large_blue_circle" => "๐Ÿ”ต", "large_blue_diamond" => "๐Ÿ”ท", "large_orange_diamond" => "๐Ÿ”ถ", "small_blue_diamond" => "๐Ÿ”น", "small_orange_diamond" => "๐Ÿ”ธ", "small_red_triangle" => "๐Ÿ”บ", "small_red_triangle_down" => "๐Ÿ”ป", "thinking" => "๐Ÿค”", "broom" => "๐Ÿงน", "mechanical_arm" => "๐Ÿฆพ", "fist_left" => "๐Ÿค›", "rofl" => "๐Ÿคฃ" }; doxygen-rs-0.4.2/src/generator.rs000064400000000000000000000272240072674642500151100ustar 00000000000000use crate::emojis; use crate::parser::{parse, GrammarItem, ParseError}; /// Creates a Rustdoc string from a Doxygen string. /// /// # Errors /// /// This function can error if there are missing parts of a given Doxygen annotation (like `@param` /// missing the variable name) pub fn rustdoc(input: String) -> Result { let parsed = parse(input)?; let mut result = String::new(); let mut already_added_params = false; let mut already_added_returns = false; let mut already_added_throws = false; let mut group_started = false; for item in parsed { result += &match item { GrammarItem::Notation { meta, params, tag } => { let (str, (added_param, added_return, added_throws)) = generate_notation( tag, meta, params, ( already_added_params, already_added_returns, already_added_throws, ), ); if added_param { already_added_params = true; } if added_return { already_added_returns = true; } if added_throws { already_added_throws = true; } str } GrammarItem::Text(v) => if group_started { v.replacen("*", "", 1) } else { v }, // See GrammarItem::GroupStart => { group_started = true; String::from("# ") }, GrammarItem::GroupEnd => { group_started = false; continue }, }; } Ok(result) } fn generate_notation( tag: String, meta: Vec, params: Vec, (already_params, already_returns, already_throws): (bool, bool, bool), ) -> (String, (bool, bool, bool)) { let mut new_param = false; let mut new_return = false; let mut new_throw = false; ( match tag.as_str() { "param" => { let param = params.get(0); new_param = true; let mut str = if !already_params { "# Arguments\n\n".into() } else { String::new() }; str += &if let Some(param) = param { if meta.is_empty() { format!("* `{param}` -") } else { if let Some(second) = meta.get(1) { format!( "* `{}` (direction {}, {}) -", param, meta.get(0).unwrap(), second ) } else { format!("* `{}` (direction {}) -", param, meta.get(0).unwrap()) } } } else { String::new() }; str } "a" | "e" | "em" => { let word = params .get(0) .expect("@a/@e/@em doesn't contain a word to style"); format!("_{word}_") } "b" => { let word = params.get(0).expect("@b doesn't contain a word to style"); format!("**{word}**") } "c" | "p" => { let word = params .get(0) .expect("@c/@p doesn't contain a word to style"); format!("`{word}`") } "emoji" => { let word = params.get(0).expect("@emoji doesn't contain an emoji"); emojis::EMOJIS .get(&word.replace(':', "")) .expect("invalid emoji") .to_string() } "sa" | "see" => { let code_ref = params.get(0).expect("@sa/@see doesn't contain a reference"); format!("[`{code_ref}`]") } "retval" => { let var = params.get(0).expect("@retval doesn't contain a parameter"); new_return = true; let mut str = if !already_returns { "# Returns\n\n".into() } else { String::new() }; str += &format!("* `{var}` -"); str } "returns" | "return" | "result" => { new_return = true; if !already_returns { "# Returns\n\n".into() } else { String::new() } } "throw" | "throws" | "exception" => { new_throw = true; let exception = params.get(0).expect("@param doesn't contain a parameter"); let mut str = if !already_throws { "# Throws\n\n".into() } else { String::new() }; str += &format!("* [`{exception}`] -"); str } "note" => String::from("> **Note:** "), "since" => String::from("> Available since: "), "deprecated" => String::from("> **Deprecated** "), "remark" | "remarks" => String::from("> "), "par" => String::from("# "), "details" | "pre" | "post" => String::from("\n\n"), "brief" | "short" => String::new(), _ => String::new(), }, (new_param, new_return, new_throw), ) } #[cfg(test)] mod test { use super::*; macro_rules! test_rustdoc { ($input:literal, $expected:literal) => { let result = $crate::generator::rustdoc($input.into()).unwrap(); assert_eq!(result, $expected); }; } #[test] fn unknown_annotation() { test_rustdoc!("@thisdoesntexist Example doc", "Example doc"); } #[test] fn param_with_direction() { test_rustdoc!( "@param[in] example This insane thing.", "# Arguments\n\n* `example` (direction in) - This insane thing." ); test_rustdoc!( "@param[in,out] example This insane thing.", "# Arguments\n\n* `example` (direction in, out) - This insane thing." ); test_rustdoc!( "@param[out,in] example This insane thing.", "# Arguments\n\n* `example` (direction in, out) - This insane thing." ); } #[test] fn param_without_direction() { test_rustdoc!( "@param example This is definitively an example!", "# Arguments\n\n* `example` - This is definitively an example!" ); } #[test] fn multiple_params() { test_rustdoc!( "@param example1 This is the first example\n@param[out] example2 This is the second example\n@param[in] example3 This is the third example.", "# Arguments\n\n* `example1` - This is the first example\n* `example2` (direction out) - This is the second example\n* `example3` (direction in) - This is the third example." ); } #[test] fn italics() { test_rustdoc!( "This @a thing is without a doubt @e great. @em And you won't tell me otherwise.", "This _thing_ is without a doubt _great._ _And_ you won't tell me otherwise." ); } #[test] fn bold() { test_rustdoc!("This is a @b bold claim.", "This is a **bold** claim."); } #[test] fn code_inline() { test_rustdoc!( "@c u8 is not the same as @p u32", "`u8` is not the same as `u32`" ); } #[test] fn emoji() { test_rustdoc!("@emoji :relieved: @emoji :ok_hand:", "๐Ÿ˜Œ ๐Ÿ‘Œ"); } #[test] fn text_styling() { test_rustdoc!( "This is from @a Italy. ( @b I @c hope @emoji :pray: )", "This is from _Italy._ ( **I** `hope` ๐Ÿ™ )" ); } #[test] fn brief() { test_rustdoc!( "@brief This function does things.\n@short This function also does things.", "This function does things.\nThis function also does things." ); } #[test] fn see_also() { test_rustdoc!( "@sa random_thing @see random_thing_2", "[`random_thing`] [`random_thing_2`]" ); } #[test] fn deprecated() { test_rustdoc!( "@deprecated This function is deprecated!\n@param example_1 Example 1.", "> **Deprecated** This function is deprecated!\n# Arguments\n\n* `example_1` - Example 1." ); } #[test] fn details() { test_rustdoc!( "@brief This function is insane!\n@details This is an insane function because its functionality and performance is quite astonishing.", "This function is insane!\n\n\nThis is an insane function because its functionality and performance is quite astonishing." ); } #[test] fn paragraph() { test_rustdoc!( "@par Interesting fact about this function\nThis is a function.", "# Interesting fact about this function\nThis is a function." ); } #[test] fn remark() { test_rustdoc!( "@remark This things needs to be\n@remark remarked.", "> This things needs to be\n> remarked." ); } #[test] fn returns() { test_rustdoc!( "@returns A value that should be\n@return used with caution.\n@result And if it's @c -1 ... run.", "# Returns\n\nA value that should be\nused with caution.\nAnd if it's `-1` ... run." ); } #[test] fn return_value() { test_rustdoc!( "@retval example1 This return value is great!", "# Returns\n\n* `example1` - This return value is great!" ); } #[test] fn returns_and_return_value() { test_rustdoc!( "@returns Great values!\n@retval example1 Is this an example?\n@return Also maybe more things (?)", "# Returns\n\nGreat values!\n* `example1` - Is this an example?\nAlso maybe more things (?)" ); test_rustdoc!( "@returns Great values!\n@return Also maybe more things (?)\n@retval example1 Is this an example?", "# Returns\n\nGreat values!\nAlso maybe more things (?)\n* `example1` - Is this an example?" ); test_rustdoc!( "@retval example1 Is this an example?\n@returns Great values!\n@return Also maybe more things (?)", "# Returns\n\n* `example1` - Is this an example?\nGreat values!\nAlso maybe more things (?)" ); } #[test] fn since() { test_rustdoc!( "@since The bite of '87", "> Available since: The bite of '87" ); } #[test] fn throws() { test_rustdoc!( "@throw std::io::bonk This is thrown when INSANE things happen.\n@throws std::net::meow This is thrown when BAD things happen.\n@exception std::fs::no This is thrown when NEFARIOUS things happen.", "# Throws\n\n* [`std::io::bonk`] - This is thrown when INSANE things happen.\n* [`std::net::meow`] - This is thrown when BAD things happen.\n* [`std::fs::no`] - This is thrown when NEFARIOUS things happen." ); } #[test] fn can_parse_example() { let example = include_str!("../tests/assets/example-bindgen.rs"); println!("{}", rustdoc(example.into()).unwrap()); } } doxygen-rs-0.4.2/src/lexer.rs000064400000000000000000000073370072674642500142440ustar 00000000000000#[derive(Debug, Clone, Eq, PartialEq)] pub(crate) enum LexItem { At(String), Paren(char), Word(String), Space, NewLine, } pub(crate) fn lex(input: String) -> Vec { let mut result = vec![]; for c in input.chars() { match c { '@' => { result.push(LexItem::At(c.into())); } '\\' => { if let Some(value) = result.last_mut() { match value { LexItem::At(v) => { if v == "\\" { *v += "\\" } else { result.push(LexItem::At(c.into())) } } _ => result.push(LexItem::At(c.into())), } } else { result.push(LexItem::At(c.into())); } } '{' | '}' => { result.push(LexItem::Paren(c)); } ' ' => { if let Some(v) = result.last_mut() { if !matches!(v, LexItem::Space) { result.push(LexItem::Space); } } } '\n' => { result.push(LexItem::NewLine); } _ => { if let Some(v) = result.last_mut() { match v { LexItem::Word(v) => *v += &c.to_string(), _ => result.push(LexItem::Word(String::from(c))), } } else { result.push(LexItem::Word(String::from(c))) } } } } result } #[cfg(test)] mod test { use super::*; #[test] fn basic_notation() { let result = lex("@name Memory Management".into()); assert_eq!( result, vec![ LexItem::At("@".into()), LexItem::Word("name".into()), LexItem::Space, LexItem::Word("Memory".into()), LexItem::Space, LexItem::Word("Management".into()) ] ); let result = lex("\\name Memory Management".into()); assert_eq!( result, vec![ LexItem::At("\\".into()), LexItem::Word("name".into()), LexItem::Space, LexItem::Word("Memory".into()), LexItem::Space, LexItem::Word("Management".into()) ] ); let result = lex("\\\\name Memory Management".into()); assert_eq!( result, vec![ LexItem::At("\\\\".into()), LexItem::Word("name".into()), LexItem::Space, LexItem::Word("Memory".into()), LexItem::Space, LexItem::Word("Management".into()) ] ); } #[test] fn basic_groups() { let result = lex("@{\n* @name Memory Management\n@}".into()); assert_eq!( result, vec![ LexItem::At("@".into()), LexItem::Paren('{'), LexItem::NewLine, LexItem::Word("*".into()), LexItem::Space, LexItem::At("@".into()), LexItem::Word("name".into()), LexItem::Space, LexItem::Word("Memory".into()), LexItem::Space, LexItem::Word("Management".into()), LexItem::NewLine, LexItem::At("@".into()), LexItem::Paren('}') ] ); } } doxygen-rs-0.4.2/src/lib.rs000064400000000000000000000021620072674642500136620ustar 00000000000000//! Simple Doxygen to Rustdoc translation. //! //! Provides a simple and straightforward API to translate _raw_ Doxygen comments to Rustdoc //! comments. Purely experimental right now, maybe practical in a future? //! //! # Examples //! //! ``` //! use doxygen_rs::transform; //! //! let rustdoc = transform("@brief Example Doxygen brief"); //! assert_eq!(rustdoc, "Example Doxygen brief"); //! ``` //! //! # Usage with bindgen >= 0.63 //! //! ``` //! # trait ParseCallbacks { //! # fn process_comment(&self, comment: &str) -> Option; //! # } //! #[derive(Debug)] //! struct Cb; //! //! impl ParseCallbacks for Cb { //! fn process_comment(&self, comment: &str) -> Option { //! Some(doxygen_rs::transform(comment)) //! } //! } //! ``` mod emojis; pub mod generator; mod lexer; mod parser; /// This function transforms the Doxygen of a single element (function, struct, etc.) /// /// # Panics /// /// This function will panic if any error from [`generator::rustdoc`] is returned. pub fn transform(value: &str) -> String { generator::rustdoc(value.into()).expect("failed to transform the comments") } doxygen-rs-0.4.2/src/parser.rs000064400000000000000000000214250072674642500144130ustar 00000000000000use crate::lexer::{lex, LexItem}; const OPEN_PAREN: char = '{'; const CLOSED_PAREN: char = '}'; #[derive(Debug, Clone)] pub enum ParseError { UnexpectedEndOfInput, UnexpectedInput { found: String, expected: Vec, }, } #[derive(Debug, Clone, Eq, PartialEq)] pub(crate) enum GrammarItem { Notation { meta: Vec, params: Vec, tag: String, }, Text(String), GroupStart, GroupEnd, } pub(crate) fn parse(input: String) -> Result, ParseError> { let mut lexed = lex(input); lexed.push(LexItem::Space); lexed.push(LexItem::Space); lexed.push(LexItem::Space); parse_items(lexed) } fn parse_items(input: Vec) -> Result, ParseError> { let mut grammar_items = vec![]; let mut param_iter_skip_count = 0; for item in input.windows(4) { let current = item.get(0).unwrap(); let next = item.get(1); match current { LexItem::At(_) => { if let Some(next) = next { match next { LexItem::Paren(v) => match *v { OPEN_PAREN => grammar_items.push(GrammarItem::GroupStart), CLOSED_PAREN => grammar_items.push(GrammarItem::GroupEnd), _ => { return Err(ParseError::UnexpectedInput { found: v.to_string(), expected: vec![OPEN_PAREN.into(), CLOSED_PAREN.into()], }) } }, LexItem::Word(v) => { let mut meta = vec![]; let params; let content; if v.starts_with("param") { let value = v.split('[').collect::>(); match value.get(1) { Some(&"in]") => meta.push("in".into()), Some(&"out]") => meta.push("out".into()), Some(&"in,out]") | Some(&"out,in]") => { meta.push("in".into()); meta.push("out".into()); } _ => match value.get(1) { None => {} Some(v) => { return Err(ParseError::UnexpectedInput { found: v.to_string(), expected: vec!["in]".into(), "out]".into()], }) } }, } params = match item.get(3) { None => vec![], Some(LexItem::Word(v)) => vec![v.into()], Some(_) => vec![], }; content = "param" } else { content = v; params = match v.as_str() { "a" | "b" | "c" | "p" | "emoji" | "e" | "em" | "def" | "class" | "category" | "concept" | "enum" | "example" | "extends" | "file" | "sa" | "see" | "retval" | "exception" | "throw" | "throws" => match item.get(3) { None => vec![], Some(LexItem::Word(v)) => vec![v.into()], Some(_) => vec![], }, _ => vec![], }; } if params.is_empty() { param_iter_skip_count = 1; } else { param_iter_skip_count = 2; } grammar_items.push(GrammarItem::Notation { meta, params, tag: content.into(), }); } _ => {} } } } LexItem::Word(v) => { if param_iter_skip_count > 0 { param_iter_skip_count -= 1; continue; } if let Some(prev) = grammar_items.last_mut() { match prev { GrammarItem::Text(text) => *text += v, _ => grammar_items.push(GrammarItem::Text(v.into())), } } else { grammar_items.push(GrammarItem::Text(v.into())); } } LexItem::Space => { if let Some(prev) = grammar_items.last_mut() { match prev { GrammarItem::Text(text) => *text += " ", _ => grammar_items.push(GrammarItem::Text("".into())), } } else { grammar_items.push(GrammarItem::Text(" ".into())) } } LexItem::NewLine => { if let Some(GrammarItem::Text(text)) = grammar_items.last_mut() { *text += "\n" } } LexItem::Paren(v) => { if let Some(GrammarItem::Text(text)) = grammar_items.last_mut() { *text += &v.to_string() } } } } Ok(grammar_items) } #[cfg(test)] mod test { use super::*; #[test] pub fn simple_notation() { let result = parse("@name Memory Management".into()).unwrap(); assert_eq!( result, vec![ GrammarItem::Notation { meta: vec![], params: vec![], tag: "name".into(), }, GrammarItem::Text("Memory Management".into()) ] ); } #[test] pub fn paren_in_notation() { let result = parse("@note hoge_t = {a, b, c}".into()).unwrap(); assert_eq!( result, vec![ GrammarItem::Notation { meta: vec![], params: vec![], tag: "note".into(), }, GrammarItem::Text("hoge_t = {a, b, c}".into()) ] ); } #[test] pub fn param() { let result = parse("@param[in] random This is, without a doubt, a random argument.".into()).unwrap(); assert_eq!( result, vec![ GrammarItem::Notation { meta: vec!["in".into()], params: vec!["random".into()], tag: "param".into(), }, GrammarItem::Text(" This is, without a doubt, a random argument.".into()) ] ); } #[test] pub fn groups() { let result = parse("@{\n* @name Memory Management\n@}".into()).unwrap(); assert_eq!( result, vec![ GrammarItem::GroupStart, GrammarItem::Text("* ".into()), GrammarItem::Notation { meta: vec![], params: vec![], tag: "name".into(), }, GrammarItem::Text("Memory Management\n".into()), GrammarItem::GroupEnd ] ); } #[test] pub fn trims_param_texts() { let result = parse("@param[in] var Example description".into()).unwrap(); assert_eq!( result, vec![ GrammarItem::Notation { meta: vec!["in".into()], params: vec!["var".into()], tag: "param".into(), }, GrammarItem::Text(" Example description".into()) ] ) } } doxygen-rs-0.4.2/tests/assets/example-bindgen.rs000064400000000000000000000031400072674642500200250ustar 00000000000000extern "C" { #[must_use] #[doc = "@name Memory management"] #[doc = "@{"] #[doc = "**"] #[doc = "* @brief Controls memory mapping"] #[doc = "* @param[out] addr_out The virtual address resulting from the operation. Usually the same as addr0."] #[doc = "* @param addr0 The virtual address to be used for the operation."] #[doc = "* @param addr1 The virtual address to be (un)mirrored by @p addr0 when using @ref MEMOP_MAP or @ref MEMOP_UNMAP."] #[doc = "* It has to be pointing to a RW memory."] #[doc = "* Use NULL if the operation is @ref MEMOP_FREE or @ref MEMOP_ALLOC."] #[doc = "* @param size The requested size for @ref MEMOP_ALLOC and @ref MEMOP_ALLOC_LINEAR."] #[doc = "* @param op Operation flags. See @ref MemOp."] #[doc = "* @param perm A combination of @ref MEMPERM_READ and @ref MEMPERM_WRITE. Using MEMPERM_EXECUTE will return an error."] #[doc = "* Value 0 is used when unmapping memory."] #[doc = "*"] #[doc = "* If a memory is mapped for two or more addresses, you have to use MEMOP_UNMAP before being able to MEMOP_FREE it."] #[doc = "* MEMOP_MAP will fail if @p addr1 was already mapped to another address."] #[doc = "*"] #[doc = "* More information is available at http://3dbrew.org/wiki/SVC#Memory_Mapping."] #[doc = "*"] #[doc = "* @sa svcControlProcessMemory"] #[doc = "*/"] pub fn svcControlMemory( addr_out: *mut u32_, addr0: u32_, addr1: u32_, size: u32_, op: MemOp, perm: MemPerm, ) -> Result; }