Skip to content

Commit

Permalink
rename "doc example" to "snippet"
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk committed Mar 14, 2024
1 parent 302ce8e commit 79bc0ed
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions crates/re_types_builder/src/bin/build_re_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use camino::Utf8Path;
const RE_TYPES_SOURCE_HASH_PATH: &str = "crates/re_types/source_hash.txt";
const DEFINITIONS_DIR_PATH: &str = "crates/re_types/definitions";
const ENTRYPOINT_PATH: &str = "crates/re_types/definitions/rerun/archetypes.fbs";
const DOC_EXAMPLES_DIR_PATH: &str = "docs/snippets/all";
const SNIPPETS_DIR_PATH: &str = "docs/snippets/all";
const CPP_OUTPUT_DIR_PATH: &str = "rerun_cpp";
const PYTHON_OUTPUT_DIR_PATH: &str = "rerun_py/rerun_sdk/rerun";
const PYTHON_TESTING_OUTPUT_DIR_PATH: &str = "rerun_py/tests/test_types";
Expand Down Expand Up @@ -84,7 +84,7 @@ fn main() {

let new_hash = compute_re_types_hash(&SourceLocations {
definitions_dir: DEFINITIONS_DIR_PATH,
doc_examples_dir: DOC_EXAMPLES_DIR_PATH,
snippets_dir: SNIPPETS_DIR_PATH,
python_output_dir: PYTHON_OUTPUT_DIR_PATH,
cpp_output_dir: CPP_OUTPUT_DIR_PATH,
});
Expand Down
9 changes: 4 additions & 5 deletions crates/re_types_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ pub fn compute_re_types_builder_hash() -> String {

pub struct SourceLocations<'a> {
pub definitions_dir: &'a str,
pub doc_examples_dir: &'a str,
pub snippets_dir: &'a str,
pub python_output_dir: &'a str,
pub cpp_output_dir: &'a str,
}
Expand All @@ -341,8 +341,7 @@ pub fn compute_re_types_hash(locations: &SourceLocations<'_>) -> String {
// code generator itself!
let re_types_builder_hash = compute_re_types_builder_hash();
let definitions_hash = compute_dir_hash(locations.definitions_dir, Some(&["fbs"]));
let doc_examples_hash =
compute_dir_hash(locations.doc_examples_dir, Some(&["rs", "py", "cpp"]));
let snippets_hash = compute_dir_hash(locations.snippets_dir, Some(&["rs", "py", "cpp"]));
let python_extensions_hash = compute_dir_filtered_hash(locations.python_output_dir, |path| {
path.to_str().unwrap().ends_with("_ext.py")
});
Expand All @@ -353,14 +352,14 @@ pub fn compute_re_types_hash(locations: &SourceLocations<'_>) -> String {
let new_hash = compute_strings_hash(&[
&re_types_builder_hash,
&definitions_hash,
&doc_examples_hash,
&snippets_hash,
&python_extensions_hash,
&cpp_extensions_hash,
]);

re_log::debug!("re_types_builder_hash: {re_types_builder_hash:?}");
re_log::debug!("definitions_hash: {definitions_hash:?}");
re_log::debug!("doc_examples_hash: {doc_examples_hash:?}");
re_log::debug!("snippets_hash: {snippets_hash:?}");
re_log::debug!("python_extensions_hash: {python_extensions_hash:?}");
re_log::debug!("cpp_extensions_hash: {cpp_extensions_hash:?}");
re_log::debug!("new_hash: {new_hash:?}");
Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ file(GLOB sources_list true ${CMAKE_CURRENT_SOURCE_DIR}/all/*.cpp)
# TODO(ab): incomplete code, need hideable stubs, see https://github.com/rerun-io/landing/issues/515
list(REMOVE_ITEM sources_list ${CMAKE_CURRENT_SOURCE_DIR}/all/timelines_example.cpp)

add_custom_target(doc_examples)
add_custom_target(snippets)

foreach(SOURCE_PATH ${sources_list})
get_filename_component(SOURCE_NAME ${SOURCE_PATH} NAME_WLE)
Expand All @@ -22,7 +22,7 @@ foreach(SOURCE_PATH ${sources_list})
rerun_strict_warning_settings(${EXAMPLE_TARGET})
target_link_libraries(${EXAMPLE_TARGET} PRIVATE rerun_sdk)

add_dependencies(doc_examples ${EXAMPLE_TARGET})
add_dependencies(snippets ${EXAMPLE_TARGET})
endforeach()

# `text_log_integration` uses `loguru` as the example text logging library.
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Most of these examples are automatically used as docstrings for the `Archetype`
You can run each example individually using the following:

- **C++**:
- `pixi run cpp-build-doc-examples` to compile all examples
- `pixi run cpp-build-snippets` to compile all examples
- `./build/docs/snippets/all/<example_name>` to run, e.g. `./build/docs/snippets/all/point3d_random`
- **Python**: `python <example_name>.py`, e.g. `python point3d_random.py`.
- **Rust**: `cargo run -p snippets -- <example_name> [args]`, e.g. `cargo run -p snippets -- point3d_random`.
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/compare_snippet_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main() -> None:
print("----------------------------------------------------------")
print("Build rerun_c & rerun_cpp…")
start_time = time.time()
run(["pixi", "run", "cpp-build-doc-examples"])
run(["pixi", "run", "cpp-build-snippets"])
elapsed = time.time() - start_time
print(f"rerun-sdk for C++ built in {elapsed:.1f} seconds")
print("")
Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ cpp-build:
cpp-build-examples:
pixi run cpp-build-examples

# Build all our C++ api doc examples.
cpp-build-doc-examples:
pixi run cpp-build-doc-examples
# Build all our C++ snippets.
cpp-build-snippets:
pixi run cpp-build-snippets

# Run our C++ tests
cpp-test:
Expand Down
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ cpp-build-roundtrips = { cmd = "cmake --build build/debug --config Debug --targe
cpp-build-examples = { cmd = "cmake --build build/debug --config Debug --target examples", depends_on = [
"cpp-prepare",
] }
cpp-build-doc-examples = { cmd = "cmake --build build/debug --config Debug --target doc_examples", depends_on = [
cpp-build-snippets = { cmd = "cmake --build build/debug --config Debug --target snippets", depends_on = [
"cpp-prepare",
] }
cpp-build-log-benchmark = { cmd = "cmake --build build/release --config Release --target log_benchmark", depends_on = [
Expand Down
6 changes: 3 additions & 3 deletions scripts/screenshot_compare/build_screenshot_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
INDEX_TEMPLATE = Template((TEMPLATE_DIR / "index.html").read_text())
EXAMPLE_TEMPLATE = Template((TEMPLATE_DIR / "example.html").read_text())
RERUN_DIR = SCRIPT_DIR_PATH.parent.parent
SNIPPET_DIR = RERUN_DIR / "docs" / "snippets"
SNIPPETS_DIR = RERUN_DIR / "docs" / "snippets"


def measure_thumbnail(url: str) -> Any:
Expand Down Expand Up @@ -125,7 +125,7 @@ def extract_snippet_urls_from_fbs() -> dict[str, str]:

def build_snippets() -> None:
cmd = [
str(SNIPPET_DIR / "roundtrips.py"),
str(SNIPPETS_DIR / "roundtrips.py"),
"--no-py",
"--no-cpp",
"--no-py-build",
Expand All @@ -138,7 +138,7 @@ def build_snippets() -> None:

def collect_snippets() -> Iterable[Example]:
for name in sorted(SNIPPET_URLS.keys()):
rrd = SNIPPET_DIR / f"{name}_rust.rrd"
rrd = SNIPPETS_DIR / f"{name}_rust.rrd"
assert rrd.exists(), f"Missing {rrd} for {name}"
yield Example(name=name, title=name, rrd=rrd, screenshot_url=SNIPPET_URLS[name])

Expand Down

0 comments on commit 79bc0ed

Please sign in to comment.