Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v1.2.0 (2025-07-11)
- added --no-server option

## v1.2.0 (2023-08-22)

### Feat
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ build the project documentation, and start the server. If
there's an error in any of these steps, the tool will print
an error message and return an error code.

### The `--no-server` Argument
When passed `--no-server`, starting the server is skipped.

## Known Issues

### Missing MkDocs Plugins
Expand Down
50 changes: 32 additions & 18 deletions src/check_mkdocs/check_mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def main(argv: None = None) -> int:
`serve(config_file=config_file)` function. If there is an error during the
server start process, it returns a user-friendly error message.

If --no-server is passed as an argument, starting the server is skipped.

Finally, the function returns 0 if all the above processes are successful.
"""
parser = argparse.ArgumentParser()
Expand All @@ -105,6 +107,15 @@ def main(argv: None = None) -> int:
default=False,
help="Flag to generate a build of the documentation in your project. Default is False.",
)

parser.add_argument(
"--no-server",
dest="no_server",
action="store_true",
default=False,
help="Flag to skip starting the mkdocs as a server. Default is False.",
)

parser.add_argument(
"--custom-tags",
dest="custom_tags",
Expand Down Expand Up @@ -170,25 +181,28 @@ def main(argv: None = None) -> int:
config_file, "Error building the documentation", e
)

print("Trying to start the server...")
# Start the server
try:
server_process = subprocess.Popen(
[
"mkdocs",
"serve",
"--config-file",
config_file,
"--no-livereload",
"--dirty",
]
)
time.sleep(5) # wait for 5 seconds to let the server start
print("Shutting down...")
server_process.terminate()
server_process.wait()
except Exception as e:
return _generate_user_friendly_error_message(config_file, "Error starting the server", e)
if not args.no_server:
print("Trying to start the server...")
try:
server_process = subprocess.Popen(
[
"mkdocs",
"serve",
"--config-file",
config_file,
"--no-livereload",
"--dirty",
]
)
time.sleep(5) # wait for 5 seconds to let the server start
print("Shutting down...")
server_process.terminate()
server_process.wait()
except Exception as e:
return _generate_user_friendly_error_message(
config_file, "Error starting the server", e
)

return 0

Expand Down