Skip to content

Commit

Permalink
- document all modules in relay compiler
Browse files Browse the repository at this point in the history
Reviewed By: evanyeung

Differential Revision: D65649100

fbshipit-source-id: e92c395bcd98b946125ad029eaa2e6358dbe7482
  • Loading branch information
lynnshaoyu authored and facebook-github-bot committed Nov 9, 2024
1 parent 08fef89 commit 86301c7
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 3 deletions.
5 changes: 5 additions & 0 deletions compiler/crates/relay-compiler/src/artifact_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

//! Artifact content refers to the generated code that is produced by the Relay compiler during the compilation process
//! to be used by Relay runtime.
//!
//! The artifact content module provides functionality for generating and managing different types of artifact content,
//! such as operations, fragments, and resolvers schema modules.
pub mod content;
pub mod content_section;

Expand Down
11 changes: 8 additions & 3 deletions compiler/crates/relay-compiler/src/build_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/

//! This module is responsible to build a single project. It does not handle
//! watch mode or other state.
//! The `build_project` module is responsible for building a single Relay project, and does not
//! handle watch mode or other state.
//!
//! This module takes a `ProjectConfig` as input and returns a `Result` containing the built project,
//! or an error if the build failed. The main entrypoint function `build_project` performs several steps including:
//! * Reading the schema from the specified location
//! * Processing the GraphQL documents in the project
//! * Generating the necessary artifacts (e.g. generated files)
mod artifact_generated_types;
pub mod artifact_writer;
mod build_ir;
Expand Down
7 changes: 7 additions & 0 deletions compiler/crates/relay-compiler/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

//! The compiler module compiles Relay source code into efficient and optimized runtime artifacts.
//!
//! The main entrypoint function for this module is `compile`. It performs several steps including:
//! * Parsing GraphQL sources into an abstract syntax tree (AST)
//! * Validating the AST against the GraphQL specification
//! * Applying transformations to the AST
//! * Generating output files based on the transformed AST
use std::collections::HashSet;
use std::sync::Arc;

Expand Down
7 changes: 7 additions & 0 deletions compiler/crates/relay-compiler/src/compiler_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

//! The `compiler_state` module manages the state of the Relay compiler.
//!
//! This module provides a way to manage the state of the Relay compiler, including the current project,
//! schema, and other configuration options. It also provides methods for updating the state and
//! generating artifacts.
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::env;
Expand Down Expand Up @@ -332,6 +337,7 @@ enum FileSourceIntermediateResult {
}

impl CompilerState {
/// Creates a new instance of the compiler state from the given file source changes.
pub fn from_file_source_changes(
config: &Config,
file_source_changes: &FileSourceResult,
Expand Down Expand Up @@ -533,6 +539,7 @@ impl CompilerState {
}

/// Merges pending changes from the file source into the compiler state.
///
/// Returns a boolean indicating if any new changes were merged.
pub fn merge_file_source_changes(
&mut self,
Expand Down
1 change: 1 addition & 0 deletions compiler/crates/relay-compiler/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

//! The config module provides functionality for managing the configuration of the Relay compiler.
use std::env::current_dir;
use std::ffi::OsStr;
use std::fmt;
Expand Down
7 changes: 7 additions & 0 deletions compiler/crates/relay-compiler/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

//! The errors module provides functionality for handling and reporting errors in the Relay compiler.
//!
//! This module contains a set of error types used throughout the Relay compiler to represent different types of
//! errors that can occur during the compilation process:
//! * `Error`: A general-purpose error type that represents any error that can occur during compilation.
//! * `BuildProjectError`: An error type that represents an error that occurred while building a project.
//! * `PersistError`: An error type that represents an error that occurred while persisting data.
use std::io;
use std::path::PathBuf;

Expand Down
5 changes: 5 additions & 0 deletions compiler/crates/relay-compiler/src/file_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

//! This module provides functionality for working with file sources in the Relay compiler.
//!
//! A file source represents a source code file that contains GraphQL code, such as files with `.graphql` or `.js` extensions (the
//! extension can be set in the relay compiler config). The `FileSource` struct represents a connection to a file source,
//! and provides methods for reading and parsing the contents of the file.
mod external_file_source;
mod extract_graphql;
mod file_categorizer;
Expand Down
5 changes: 5 additions & 0 deletions compiler/crates/relay-compiler/src/status_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

//! The status reporter module provides functionality for reporting the status of the Relay compiler.
//!
//! This module contains two implementations of the `StatusReporter` trait:
//! * `ConsoleStatusReporter`: Reports the status to the console using the `log` crate.
//! * `JSONStatusReporter`: Reports the status to a JSON file using the `serde_json` crate.
use std::path::PathBuf;

use common::Diagnostic;
Expand Down

0 comments on commit 86301c7

Please sign in to comment.