docs: def serve(args):
      """Start a server which will watch .md and .rst files for changes.
      If a md file changes, the Home Documentation is rebuilt. If a .rst
      file changes, the updated sphinx project is rebuilt
  
      Args:
          args (ArgumentParser): flags from the CLI
      """
      # Sever's parameters
      port = args.serve_port or PORT
      host = "0.0.0.0"
  
      # Current working directory
      dir_path = Path().absolute()
      web_dir = dir_path / "site"
  
      # Update routes
      utils.set_routes()
  
      # Offline mode
      if args.offline:
          os.environ["MKINX_OFFLINE"] = "true"
          _ = subprocess.check_output("mkdocs build > /dev/null", shell=True)
          utils.make_offline()
  
      class MkinxHTTPHandler(SimpleHTTPRequestHandler):
          """Class routing urls (paths) to projects (resources)
          """
  
          def translate_path(self, path):
              # default root -> cwd
              location = str(web_dir)
              route = location
  
              if len(path) != 0 and path != "/":
                  for key, loc in utils.get_routes():
                      if path.startswith(key):
                          location = loc
                          path = path[len(key) :]
                          break
  
              if location[-1] == "/" or not path or path[0] == "/":
                  route = location + path
              else:
                  route = location + "/" + path
  
              return route.split("?")[0]
  
      # Serve as deamon thread
      success = False
      count = 0
      print("Waiting for server port...")
      try:
          while not success:
              try:
                  httpd = socketserver.TCPServer((host, port), MkinxHTTPHandler)
                  success = True
              except OSError:
                  count += 1
              finally:
                  if not success and count > 20:
                      s = "port {} seems occupied. Try with {} ? (y/n)"
                      if "y" in input(s.format(port, port + 1)):
                          port += 1
                          count = 0
                      else:
                          print("You can specify a custom port with mkinx serve -s")
                          return
                  time.sleep(0.5)
      except KeyboardInterrupt:
          print("Aborting.")
          return
  
      httpd.allow_reuse_address = True
      print("\nServing at http://{}:{}\n".format(host, port))
      thread = threading.Thread(target=httpd.serve_forever)
      thread.daemon = True
      thread.start()
  
      # Watch for changes
      event_handler = utils.MkinxFileHandler(
          patterns=["*.rst", "*.md", "*.yml", "*.yaml"]
      )
      observer = Observer()
      observer.schedule(event_handler, path=str(dir_path), recursive=True)
      observer.start()
  
      try:
          while True:
              time.sleep(1)
      except KeyboardInterrupt:
          observer.stop()
          httpd.server_close()
      observer.join()