|
27 | 27 | is_flag=True, |
28 | 28 | help="Start the development server for all content types and the project website", |
29 | 29 | ) |
| 30 | +@click.option( |
| 31 | + "--doc", |
| 32 | + is_flag=True, |
| 33 | + help="Start the development server for documentation content", |
| 34 | +) |
| 35 | +@click.option( |
| 36 | + "--blog", |
| 37 | + is_flag=True, |
| 38 | + help="Start the development server for blog content", |
| 39 | +) |
| 40 | +@click.option( |
| 41 | + "--tutorial", |
| 42 | + is_flag=True, |
| 43 | + help="Start the development server for tutorial content", |
| 44 | +) |
| 45 | +@click.option( |
| 46 | + "--example", |
| 47 | + is_flag=True, |
| 48 | + help="Start the development server for example content", |
| 49 | +) |
| 50 | +@click.option( |
| 51 | + "--guide", |
| 52 | + is_flag=True, |
| 53 | + help="Start the development server for guide content", |
| 54 | +) |
30 | 55 | @click.option( |
31 | 56 | "--execute", is_flag=True, help="Execute Jupyter notebooks for all content types" |
32 | 57 | ) |
33 | 58 | @click.option( |
34 | 59 | "--no-website", |
| 60 | + "-n", |
35 | 61 | is_flag=True, |
36 | 62 | help="Skip running the website dev server (pnpm dev). Useful when you want to run pnpm dev manually with custom options.", |
37 | 63 | ) |
38 | | -def dev(ctx, all: bool, execute: bool, no_website: bool): |
| 64 | +def dev( |
| 65 | + ctx, |
| 66 | + all: bool, |
| 67 | + doc: bool, |
| 68 | + blog: bool, |
| 69 | + tutorial: bool, |
| 70 | + example: bool, |
| 71 | + guide: bool, |
| 72 | + execute: bool, |
| 73 | + no_website: bool, |
| 74 | +): |
39 | 75 | """Run the development server for the project website. |
40 | 76 |
|
41 | | - If --all is enabled, starts MyST dev servers for all content types (doc/blog/tutorial/example/guide) |
42 | | - and the project website. |
| 77 | + By default, runs only the website without any content servers. |
| 78 | + Use --all to start all content types, or specify individual content types with --doc, --blog, etc. |
| 79 | +
|
| 80 | + Examples: |
| 81 | + ap dev # Website only |
| 82 | + ap dev --all # Website + all content types |
| 83 | + ap dev --doc # Website + doc content |
| 84 | + ap dev --doc --blog # Website + doc and blog content |
43 | 85 |
|
44 | 86 | Any extra arguments are passed to the MyST servers (via 'ap doc/blog/tutorial/example/guide' commands). |
45 | 87 | See "myst start --help" for more details. |
@@ -79,14 +121,35 @@ def cleanup_processes(): |
79 | 121 | except Exception: |
80 | 122 | pass |
81 | 123 |
|
| 124 | + # Determine which content types to run |
| 125 | + if all: |
| 126 | + enabled_content_types = set(CONTENT_TYPES) |
| 127 | + else: |
| 128 | + # Check individual flags |
| 129 | + content_flags = { |
| 130 | + "doc": doc, |
| 131 | + "blog": blog, |
| 132 | + "tutorial": tutorial, |
| 133 | + "example": example, |
| 134 | + "guide": guide, |
| 135 | + } |
| 136 | + assert set(content_flags.keys()) == set(CONTENT_TYPES), ( |
| 137 | + "Incomplete content flags" |
| 138 | + ) |
| 139 | + enabled_content_types = {ct for ct, flag in content_flags.items() if flag} |
| 140 | + |
82 | 141 | try: |
83 | | - if all: |
| 142 | + if enabled_content_types: |
84 | 143 | # Clear .env.development before writing new ports |
85 | 144 | env_file = paths.website_path / ".env.development" |
86 | 145 | env_file.write_text("") # Clear existing content |
87 | 146 |
|
88 | 147 | next_port = 3000 |
89 | 148 | for content_type in CONTENT_TYPES: |
| 149 | + # Skip content types that are not enabled |
| 150 | + if content_type not in enabled_content_types: |
| 151 | + continue |
| 152 | + |
90 | 153 | # Find available port for MyST server |
91 | 154 | myst_port = find_available_port(start_port=next_port) |
92 | 155 | next_port = myst_port + 1 |
@@ -134,7 +197,7 @@ def cleanup_processes(): |
134 | 197 | click.echo( |
135 | 198 | "Skipping website dev server (--no-website flag). Run 'pnpm dev' manually in afterpython/_website/ with your custom options." |
136 | 199 | ) |
137 | | - if all: |
| 200 | + if enabled_content_types: |
138 | 201 | # Keep the process running to maintain MyST servers |
139 | 202 | click.echo("Press Ctrl+C to stop MyST servers...") |
140 | 203 | while True: |
|
0 commit comments