Skip to content

Commit e5e3b65

Browse files
committed
Hide the entire header and markmap modules.
1 parent 0f15c0e commit e5e3b65

3 files changed

Lines changed: 24 additions & 33 deletions

File tree

cfgrammar/src/lib/header.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl From<HeaderError<Span>> for YaccGrammarError {
4141
// This is essentially a tuple that needs a newtype so we can implement `From` for it.
4242
// Thus we aren't worried about it being `pub`.
4343
#[derive(Debug, PartialEq)]
44+
#[doc(hidden)]
4445
pub struct HeaderValue<T>(pub T, pub Value<T>);
4546

4647
impl From<HeaderValue<Span>> for HeaderValue<Location> {
@@ -429,6 +430,7 @@ impl<'input> GrmtoolsSectionParser<'input> {
429430
}
430431

431432
/// A data structure representation of the %grmtools section.
433+
#[doc(hidden)]
432434
pub type Header<T> = MarkMap<String, HeaderValue<T>>;
433435

434436
impl TryFrom<YaccKind> for Value<Location> {

cfgrammar/src/lib/markmap.rs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@ use std::borrow::Borrow;
22
use std::error::Error;
33
use std::fmt;
44

5-
// MarkMap is a key value data structure that uses an API similar to that of
6-
// `std::collections::HashMap` and `std::collections::BTreeMap`.
7-
//
8-
// The current implementation is based on a sorted `Vec` is not optimized for
9-
// storing large number of items.
10-
//
11-
// On top of the familiar `std::collections` API it has a few additions:
12-
//
13-
// * Marking a key with a condition.
14-
// * Marking a key with a merge behavior.
15-
// * A merge operator.
16-
//
17-
// The current *conditions* are [`Used`](MarkMap::mark_used) and [`Required`](MarkMap::mark_required).
18-
//
19-
// The available merge behaviors are [`Theirs`](MergeBehavior::Theirs), [`Ours`](MergeBehavior::Ours),
20-
// and [`MutuallyExclusive`](MergeBehavior::MutuallyExclusive).
21-
//
22-
// Merge behaviors configure how the merge operator handles cases where both `MarkMaps` being merged
23-
// contain a particular key.
5+
/// MarkMap is a key value data structure that uses an API similar to that of
6+
/// `std::collections::HashMap` and `std::collections::BTreeMap`.
7+
///
8+
/// The current implementation is based on a sorted `Vec` is not optimized for
9+
/// storing large number of items.
10+
///
11+
/// On top of the familiar `std::collections` API it has a few additions:
12+
///
13+
/// * Marking a key with a condition.
14+
/// * Marking a key with a merge behavior.
15+
/// * A merge operator.
16+
///
17+
/// The current *conditions* are [`Used`](MarkMap::mark_used) and [`Required`](MarkMap::mark_required).
18+
///
19+
/// The available merge behaviors are [`Theirs`](MergeBehavior::Theirs), [`Ours`](MergeBehavior::Ours),
20+
/// and [`MutuallyExclusive`](MergeBehavior::MutuallyExclusive).
21+
///
22+
/// Merge behaviors configure how the merge operator handles cases where both `MarkMaps` being merged
23+
/// contain a particular key.
2424
#[derive(Debug, PartialEq, Eq)]
25+
#[doc(hidden)]
2526
pub struct MarkMap<K, V> {
2627
contents: Vec<(K, u16, Option<V>)>,
2728
}
@@ -219,7 +220,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
219220
}
220221

221222
/// Inserts a `key` `value` pair.
222-
#[doc(hidden)]
223223
pub fn insert(&mut self, key: K, val: V) -> Option<V> {
224224
let pos = self.contents.binary_search_by(|(k, _, _)| k.cmp(&key));
225225
match pos {
@@ -246,7 +246,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
246246
}
247247

248248
/// Marks `key` as used.
249-
#[doc(hidden)]
250249
pub fn mark_used(&mut self, key: &K) {
251250
let pos = self.contents.binary_search_by(|(k, _, _)| k.cmp(key));
252251
match pos {
@@ -263,7 +262,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
263262
}
264263

265264
/// Marks `key` as a required value.
266-
#[doc(hidden)]
267265
pub fn mark_required(&mut self, key: &K) {
268266
let pos = self.contents.binary_search_by(|(k, _, _)| k.cmp(key));
269267
match pos {
@@ -280,7 +278,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
280278
}
281279

282280
/// Returns whether `key` is required.
283-
#[doc(hidden)]
284281
pub fn is_required(&self, key: &K) -> bool {
285282
let pos = self.contents.binary_search_by(|(k, _, _)| k.cmp(key));
286283
match pos {
@@ -290,7 +287,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
290287
}
291288

292289
/// Sets the merge behavior for `key`.
293-
#[doc(hidden)]
294290
pub fn set_merge_behavior(&mut self, key: &K, mb: MergeBehavior) {
295291
let pos = self.contents.binary_search_by(|(k, _, _)| k.cmp(key));
296292
match pos {
@@ -312,7 +308,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
312308
}
313309

314310
/// Returns a `Some(value)` associated with `key` if present otherwise `None`.
315-
#[doc(hidden)]
316311
pub fn get<Q>(&self, key: &Q) -> Option<&V>
317312
where
318313
K: Borrow<Q>,
@@ -329,7 +324,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
329324
}
330325

331326
/// Returns true if the `MarkMap` contains `key` otherwise false.
332-
#[doc(hidden)]
333327
pub fn contains_key<Q>(&self, key: &Q) -> bool
334328
where
335329
K: Borrow<Q>,
@@ -339,7 +333,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
339333
}
340334

341335
/// Removes `key` from the `MarkMap` and returns the previous value when present.
342-
#[doc(hidden)]
343336
pub fn remove(&mut self, key: &K) -> Option<V> {
344337
let pos = self.contents.binary_search_by(|(k, _, _)| k.cmp(key));
345338
match pos {
@@ -349,7 +342,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
349342
}
350343

351344
/// Returns an `Entry` for `key`.
352-
#[doc(hidden)]
353345
pub fn entry(&mut self, key: K) -> Entry<K, V> {
354346
let pos = self.contents.binary_search_by(|(k, _, _)| k.cmp(&key));
355347
match pos {
@@ -382,7 +374,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
382374
///
383375
/// For the behavior of exclusive or mark the behavior as also `Mark::Required`, then after merge call `missing()`
384376
/// to check all required values.
385-
#[doc(hidden)]
386377
pub fn merge_from<U>(&mut self, mut other: MarkMap<K, U>) -> Result<(), MergeError<K, Box<V>>>
387378
where
388379
U: Into<V>,
@@ -427,7 +418,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
427418
}
428419

429420
/// Returns whether `key` has been marked as used.
430-
#[doc(hidden)]
431421
pub fn is_used<Q>(&self, key: &Q) -> bool
432422
where
433423
K: Borrow<Q>,
@@ -444,7 +434,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
444434
}
445435

446436
/// Returns a `Vec` containing all the keys that are not marked as used.
447-
#[doc(hidden)]
448437
pub fn unused(&self) -> Vec<K> {
449438
let mut ret = Vec::new();
450439
for (k, mark, v) in &self.contents {
@@ -458,7 +447,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
458447

459448
/// Returns a `Vec` containing all the keys that are marked as required,
460449
/// but have values that are not present in the `MarkMap`.
461-
#[doc(hidden)]
462450
pub fn missing(&self) -> Vec<&K> {
463451
let mut ret = Vec::new();
464452
for (k, mark, v) in &self.contents {
@@ -471,7 +459,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
471459
}
472460

473461
/// Returns an `Iterator` over all the keys of the `MarkMap`.
474-
#[doc(hidden)]
475462
pub fn keys(&self) -> Keys<'_, K, V> {
476463
Keys { pos: 0, map: self }
477464
}

cfgrammar/src/lib/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ use bincode::{Decode, Encode};
5656
#[cfg(feature = "serde")]
5757
use serde::{Deserialize, Serialize};
5858

59+
#[doc(hidden)]
5960
pub mod header;
6061
mod idxnewtype;
62+
#[doc(hidden)]
6163
pub mod markmap;
6264
pub mod newlinecache;
6365
pub mod span;

0 commit comments

Comments
 (0)