Skip to content

Commit

Permalink
lib: add short method summary to its documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Oct 4, 2024
1 parent 87840a5 commit 8ba33b7
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 28 deletions.
10 changes: 6 additions & 4 deletions lib/src/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,12 @@ pub fn materialized_diff_stream<'a>(
.buffered((store.concurrency() / 2).max(1))
}

/// Parses conflict markers from a slice. Returns None if there were no valid
/// conflict markers. The caller has to provide the expected number of merge
/// sides (adds). Conflict markers that are otherwise valid will be considered
/// invalid if they don't have the expected arity.
/// Parses conflict markers from a slice.
///
/// Returns `None` if there were no valid conflict markers. The caller
/// has to provide the expected number of merge sides (adds). Conflict
/// markers that are otherwise valid will be considered invalid if
/// they don't have the expected arity.
// TODO: "parse" is not usually the opposite of "materialize", so maybe we
// should rename them to "serialize" and "deserialize"?
pub fn parse_conflict(input: &[u8], num_sides: usize) -> Option<Vec<Merge<BString>>> {
Expand Down
12 changes: 7 additions & 5 deletions lib/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,13 @@ impl<'diff, 'input> Iterator for DiffHunkIterator<'diff, 'input> {
}
}

/// Diffs slices of bytes. The returned diff hunks may be any length (may
/// span many lines or may be only part of a line). This currently uses
/// Histogram diff (or maybe something similar; I'm not sure I understood the
/// algorithm correctly). It first diffs lines in the input and then refines
/// the changed ranges at the word level.
/// Diffs slices of bytes.
///
/// The returned diff hunks may be any length (may span many lines or
/// may be only part of a line). This currently uses Histogram diff
/// (or maybe something similar; I'm not sure I understood the
/// algorithm correctly). It first diffs lines in the input and then
/// refines the changed ranges at the word level.
pub fn diff<'a, T: AsRef<[u8]> + ?Sized + 'a>(
inputs: impl IntoIterator<Item = &'a T>,
) -> Vec<DiffHunk<'a>> {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/fsmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Filesystem monitor tool interface.
//!
//! Interfaces with a filesystem monitor tool to efficiently query for
//! filesystem updates, without having to crawl the entire working copy. This is
//! particularly useful for large working copies, or for working copies for
Expand Down
10 changes: 6 additions & 4 deletions lib/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,12 @@ impl<T: ContentHash> ContentHash for Merge<T> {
/// Borrowed `MergedTreeValue`.
pub type MergedTreeVal<'a> = Merge<Option<&'a TreeValue>>;

/// The value at a given path in a commit. It depends on the context whether it
/// can be absent (`Merge::is_absent()`). For example, when getting the value at
/// a specific path, it may be, but when iterating over entries in a tree, it
/// shouldn't be.
/// The value at a given path in a commit.
///
/// It depends on the context whether it can be absent
/// (`Merge::is_absent()`). For example, when getting the value at a
/// specific path, it may be, but when iterating over entries in a
/// tree, it shouldn't be.
pub type MergedTreeValue = Merge<Option<TreeValue>>;

impl MergedTreeValue {
Expand Down
11 changes: 7 additions & 4 deletions lib/src/merged_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,13 @@ impl Stream for TreeDiffStreamImpl<'_> {
}
}

/// Helps with writing trees with conflicts. You start by creating an instance
/// of this type with one or more base trees. You then add overrides on top. The
/// overrides may be conflicts. Then you can write the result as a legacy tree
/// (allowing path-level conflicts) or as multiple conflict-free trees.
/// Helper for writing trees with conflicts.
///
/// You start by creating an instance of this type with one or more
/// base trees. You then add overrides on top. The overrides may be
/// conflicts. Then you can write the result as a legacy tree
/// (allowing path-level conflicts) or as multiple conflict-free
/// trees.
pub struct MergedTreeBuilder {
base_tree_id: MergedTreeId,
overrides: BTreeMap<RepoPathBuf, MergedTreeValue>,
Expand Down
14 changes: 8 additions & 6 deletions lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,14 @@ pub struct MoveCommitsStats {
}

/// Moves `target_commits` from their current location to a new location in the
/// graph, given by the set of `new_parent_ids` and `new_children`.
/// The roots of `target_commits` are rebased onto the new parents, while the
/// new children are rebased onto the heads of `target_commits`.
/// This assumes that `target_commits` and `new_children` can be rewritten, and
/// there will be no cycles in the resulting graph.
/// `target_commits` should be in reverse topological order.
/// graph.
///
/// The roots of `target_commits` are rebased onto the new parents
/// given by `new_parent_ids`, while the `new_children` commits are
/// rebased onto the heads of `target_commits`. This assumes that
/// `target_commits` and `new_children` can be rewritten, and there
/// will be no cycles in the resulting graph. `target_commits` should
/// be in reverse topological order.
pub fn move_commits(
settings: &UserSettings,
mut_repo: &mut MutableRepo,
Expand Down
12 changes: 7 additions & 5 deletions lib/src/stacked_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! A persistent table of fixed-size keys to variable-size values. The keys are
//! stored in sorted order, with each key followed by an integer offset into the
//! list of values. The values are concatenated after the keys. A file may have
//! a parent file, and the parent may have its own parent, and so on. The child
//! file then represents the union of the entries.
//! A persistent table of fixed-size keys to variable-size values.
//!
//! The keys are stored in sorted order, with each key followed by an
//! integer offset into the list of values. The values are
//! concatenated after the keys. A file may have a parent file, and
//! the parent may have its own parent, and so on. The child file then
//! represents the union of the entries.

#![allow(missing_docs)]

Expand Down
2 changes: 2 additions & 0 deletions lib/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ pub fn create_op_metadata(
}
}

/// An unpublished operation in the store.
///
/// An Operation which has been written to the operation store but not
/// published. The repo can be loaded at an unpublished Operation, but the
/// Operation will not be visible in the op log if the repo is loaded at head.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ pub enum WorkspaceLoadError {
Path(#[from] PathError),
}

/// The combination of a repo and a working copy.
///
/// Represents the combination of a repo and working copy, i.e. what's typically
/// the .jj/ directory and its parent. See
/// <https://github.com/martinvonz/jj/blob/main/docs/working-copy.md#workspaces>
Expand Down

0 comments on commit 8ba33b7

Please sign in to comment.