BurntSushi / ucd-generate

A command line tool to generate Unicode tables as source code.
Apache License 2.0
95 stars 21 forks source link

Add new option to generate a Rust enum for script #15

Closed wezm closed 4 years ago

wezm commented 4 years ago

This is an extension of #14, which I've closed in favour of this PR. It adds an option to allow generating a Rust enum for script. This is designed to match servo/unicode-script pretty closely so that it can be updated to use ucd-generate. (I've done that work on the ucd-generate-unicode-12 branch of my fork).

Sample output from the --rust-enum option:

// DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY:
//
//  ucd-generate script --rust-enum /home/wmoore/Downloads/ucd-12.1
//
// ucd-generate is available on crates.io.

#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
pub enum Script {
  Unknown, Adlam, Ahom, AnatolianHieroglyphs, Arabic, Armenian, Avestan,
  Balinese, Bamum, BassaVah, Batak, Bengali, Bhaiksuki, Bopomofo, Brahmi,
  Braille, Buginese, Buhid, CanadianAboriginal, Carian, CaucasianAlbanian,
  ⋮
}

pub const SCRIPT: &'static [(u32, u32, Script)] = &[
  (0, 64, Script::Common), (65, 90, Script::Latin), (91, 96, Script::Common),
  (97, 122, Script::Latin), (123, 169, Script::Common),
  (170, 170, Script::Latin), (171, 185, Script::Common),
  (186, 186, Script::Latin), (187, 191, Script::Common),
  (192, 214, Script::Latin), (215, 215, Script::Common),
  (216, 246, Script::Latin), (247, 247, Script::Common),
  (248, 696, Script::Latin), (697, 735, Script::Common),
  (736, 740, Script::Latin), (741, 745, Script::Common),
  (746, 747, Script::Bopomofo), (748, 767, Script::Common),
  ⋮
];
wezm commented 4 years ago

Hi @BurntSushi just wanted to touch base on this PR and let you know of some other activities I've been up to in the Unicode Rust space described here: https://github.com/i18n-concept/rust-discuss/issues/11

I'd like to raise the PRs against unicode-bidi and unicode-script with a published version of ucd-generate. If there's anything I can do to help with PR review, please let me know. I do understand you are maintaining this in your own time and are under no obligation to respond. Alternatively, if you'd prefer, we (YesLogic) can publish our own version of ucd-generate (yeslogic-ucd-generate perhaps) with the necessary changes and move forward with that.

Manishearth commented 4 years ago

@BurntSushi perhaps we can transfer ownership of this repo to unicode-rs or some other commons, and grant maintainership to the various folks writing unicode crates?

BurntSushi commented 4 years ago

@Manishearth Honestly, I'd rather maintain creative control for the time being. I'm not opposed to doing that in the future, but there is at least one pending migration that I want to see ucd-generate through (#11). I've been away for a bit, but hadn't noticed anything urgent filed against this repo. I'll take a look through the PRs now. Another migration I want to see through is the use of a templating library, as the output generation code has become a bit monstrous.

Manishearth commented 4 years ago

Sounds good! I wasn't sure if this was maintained.

You might be interested in filing an issue on https://github.com/i18n-concept/rust-discuss talking about this crate, a bunch of us are hoping to join efforts for Unicode stuff in rust there.

On Thu, Jan 9, 2020, 7:44 PM Andrew Gallant notifications@github.com wrote:

@Manishearth https://github.com/Manishearth Honestly, I'd rather maintain creative control for the time being. I'm not opposed to doing that in the future, but there is at least one pending migration that I want to see ucd-generate through (#11 https://github.com/BurntSushi/ucd-generate/issues/11). I've been away for a bit, but hadn't noticed anything urgent filed against this repo. I'll take a look through the PRs now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BurntSushi/ucd-generate/pull/15?email_source=notifications&email_token=AAMK6SD55JCWVQB3SSPM7TDQ44WNNA5CNFSM4JVDH3EKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIQN4IY#issuecomment-572579363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMK6SAWJ2MAEXZNMGOCBRLQ44WNNANCNFSM4JVDH3EA .

BurntSushi commented 4 years ago

@wezm Thanks! Sorry about the tardy response. I merged this PR after tidying up a few stylistic nits. (Mostly line lengths.) I'll switch over to rustfmt and put out a new release once I clear the rest of the PR queue.

BurntSushi commented 4 years ago

This PR is in ucd-generate 0.2.4 on crates.io.

wezm commented 4 years ago

Thanks @BurntSushi I have a number of follow up PRs that build upon this one. Happy for me to raise them?

BurntSushi commented 4 years ago

Yeah definitely, bring it on!