Skip to content

Gen Cmd

CLI command for generating code documentation.

logger module-attribute

logger = getLogger(__name__)

PathArg module-attribute

PathArg = Annotated[
	Path,
	Argument(
		exists=True,
		help="Path to the codebase to analyze",
		show_default=True,
	),
]

OutputOpt module-attribute

OutputOpt = Annotated[
	Path | None,
	Option(
		"--output",
		"-o",
		help="Output file path (overrides config)",
	),
]

ConfigOpt module-attribute

ConfigOpt = Annotated[
	Path | None,
	Option("--config", "-c", help="Path to config file"),
]

MaxContentLengthOpt module-attribute

MaxContentLengthOpt = Annotated[
	int | None,
	Option(
		"--max-content-length",
		help="Maximum content length for file display (set to 0 for unlimited)",
	),
]

TreeOpt module-attribute

TreeOpt = Annotated[
	bool | None,
	Option(
		"--tree/--no-tree",
		"-t",
		help="Include directory tree in output",
	),
]

EntityGraphOpt module-attribute

EntityGraphOpt = Annotated[
	bool | None,
	Option(
		"--entity-graph/--no-entity-graph",
		"-e",
		help="Include entity relationship graph in output",
	),
]

LODLevelOpt module-attribute

LODLevelOpt = Annotated[
	str,
	Option(
		"--lod",
		help="Level of Detail for code analysis (e.g., 'full', 'docs', 'signatures')",
		case_sensitive=False,
	),
]

MermaidEntitiesOpt module-attribute

MermaidEntitiesOpt = Annotated[
	str | None,
	Option(
		"--mermaid-entities",
		help="Comma-separated list of entity types to include in Mermaid graph (e.g., 'module,class,function')",
	),
]

MermaidRelationshipsOpt module-attribute

MermaidRelationshipsOpt = Annotated[
	str | None,
	Option(
		"--mermaid-relationships",
		help="Comma-separated list of relationship types to include in Mermaid graph (e.g., 'declares,imports,calls')",
	),
]

MermaidLegendOpt module-attribute

MermaidLegendOpt = Annotated[
	bool | None,
	Option(
		"--mermaid-legend/--no-mermaid-legend",
		help="Show/hide the legend in the Mermaid diagram",
	),
]

MermaidUnconnectedOpt module-attribute

MermaidUnconnectedOpt = Annotated[
	bool | None,
	Option(
		"--mermaid-unconnected/--no-mermaid-unconnected",
		help="Remove/keep nodes with no connections in the Mermaid diagram",
	),
]

SemanticAnalysisOpt module-attribute

SemanticAnalysisOpt = Annotated[
	bool,
	Option(
		"--semantic/--no-semantic",
		help="Enable/disable semantic analysis",
	),
]

register_command

register_command(app: Typer) -> None

Register the gen command with the CLI app.

Source code in src/codemap/cli/gen_cmd.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
def register_command(app: typer.Typer) -> None:
	"""Register the gen command with the CLI app."""

	@app.command(name="gen")
	def gen_command(
		path: PathArg = Path(),
		output: OutputOpt = None,
		max_content_length: MaxContentLengthOpt = None,
		lod_level_str: LODLevelOpt = "docs",
		semantic_analysis: SemanticAnalysisOpt = True,
		tree: TreeOpt = None,
		entity_graph: EntityGraphOpt = None,
		mermaid_entities_str: MermaidEntitiesOpt = None,
		mermaid_relationships_str: MermaidRelationshipsOpt = None,
		mermaid_show_legend_flag: MermaidLegendOpt = None,
		mermaid_remove_unconnected_flag: MermaidUnconnectedOpt = None,
	) -> None:
		"""
		Generate code documentation.

		This command processes a codebase and generates Markdown documentation
		with configurable level of detail.

		Examples:
		        codemap gen                      # Generate docs for current directory
		        codemap gen --lod full           # Generate full implementation docs
		        codemap gen --lod signatures     # Generate docs with signatures only
		        codemap gen --no-semantic        # Generate without semantic analysis

		"""
		# Defer all heavy imports by calling implementation function
		_gen_command_impl(
			path=path,
			output=output,
			max_content_length=max_content_length,
			lod_level_str=lod_level_str,
			semantic_analysis=semantic_analysis,
			tree=tree,
			entity_graph=entity_graph,
			mermaid_entities_str=mermaid_entities_str,
			mermaid_relationships_str=mermaid_relationships_str,
			mermaid_show_legend_flag=mermaid_show_legend_flag,
			mermaid_remove_unconnected_flag=mermaid_remove_unconnected_flag,
		)