View Source AutoDocPackage.Utils (Auto Doc v0.1.0)
Utilities for the AutoDoc package
Summary
Functions
Create nested directories. If a directory already exists, it will not raise an error and will continue to the next one in line. If the directory does not exist, it will create it and continue to the next one in line.
Generates the file path for the documentation file.
## Examples
Guess the possible documentation's inner-most directory
for the params.ex
, responses.ex
, operations.ex
file paths.
Checks if a file exists.
Checks if a module name is a controller module.
## Examples
iex> is_controller_module?("AutoDoc.PageController")
true
iex> is_controller_module?("AutoDoc.PageView")
false
Checks if a module name is a controller test module.
## Examples
iex> is_controller_test_module?("AutoDocWeb.PageControllerTest")
true
iex> is_controller_test_module?("AutoDocWeb.PageController")
false
Checks if a module name is a test module.
## Examples
iex> is_test_module?("AutoDoc.UtilsTest")
true
iex> is_test_module?("AutoDoc.Utils")
false
Checks if a module name is a view module.
## Examples
iex> is_view_module?("AutoDoc.PageView")
true
iex> is_view_module?("AutoDoc.PageController")
false
Checks if a module name is a view test module.
## Examples
iex> is_view_test_module?("AutoDocWeb.PageViewTest")
true
iex> is_view_test_module?("AutoDocWeb.PageView")
false
Converts a module name to a path.
## Examples
iex> module_name_to_path("AutoDoc.Utils")
"auto_doc/lib/auto_doc/utils.ex"
iex> module_name_to_path("AutoDoc.UtilsTest")
"auto_doc/test/auto_doc/utils_test.exs"
Guess the possible documentation's `operations.ex` file path.
Parses the file path from relative to usable type.
Converts a path to a module name.
## Examples
iex> path_to_module_name("auto_doc/lib/auto_doc/utils.ex")
"AutoDoc.Utils"
iex> path_to_module_name("auto_doc/test/auto_doc/utils_test.exs")
"AutoDoc.UtilsTest"
Returns the name of the project container.
## Examples
iex> project_container_name()
"auto_doc"
Read file and returns the content.
Runs mix format
on given file.
Converts a string to camelCase.
## Examples
iex> to_camel_case("helloWorld")
"helloWorld"
iex> to_camel_case("hello_world")
"helloWorld"
iex> to_camel_case("HelloWorld")
"helloWorld"
iex> to_camel_case("Invalid_Type")
** (ArgumentError)
** ...
Converts a string to PascalCase.
## Examples
iex> to_pascal_case("helloWorld")
"HelloWorld"
iex> to_pascal_case("hello_world")
"HelloWorld"
iex> to_pascal_case("HelloWorld")
"HelloWorld"
iex> to_pascal_case("Invalid_Type")
** (ArgumentError)
** ...
Converts a string to snake_case.
## Examples
iex> to_snake_case("helloWorld")
"hello_world"
iex> to_snake_case("hello_world")
"hello_world"
iex> to_snake_case("HelloWorld")
"hello_world"
iex> to_snake_case("Invalid_Type")
** (ArgumentError)
** ...
Write to file.
Functions
Create nested directories. If a directory already exists, it will not raise an error and will continue to the next one in line. If the directory does not exist, it will create it and continue to the next one in line.
Important: The path should contain ONLY directories, not a file at the end or ../
in the beginning.
Generates the file path for the documentation file.
## Examples
iex> doc_file_path("auto_doc/lib/auto_doc/documentation", "lib/auto_doc_web/controllers/page_controller.ex", "params.ex")
"auto_doc/lib/auto_doc_web/documentation/page/params.ex"
Guess the possible documentation's inner-most directory
for the params.ex
, responses.ex
, operations.ex
file paths.
## Examples
iex> doc_path("auto_doc/lib/auto_doc/documentation", "lib/auto_doc_web/controllers/page_controller.ex")
"auto_doc/lib/auto_doc_web/documentation/page"
Checks if a file exists.
## Examples
iex> file_exists?("lib/auto_doc/utils.ex")
true
iex> file_exists?("auto_doc/lib/auto_doc/utils.ex")
true
iex> file_exists?("lib/auto_doc/not_existing.ex")
false
Checks if a module name is a controller module.
## Examples
iex> is_controller_module?("AutoDoc.PageController")
true
iex> is_controller_module?("AutoDoc.PageView")
false
Checks if a module name is a controller test module.
## Examples
iex> is_controller_test_module?("AutoDocWeb.PageControllerTest")
true
iex> is_controller_test_module?("AutoDocWeb.PageController")
false
Checks if a module name is a test module.
## Examples
iex> is_test_module?("AutoDoc.UtilsTest")
true
iex> is_test_module?("AutoDoc.Utils")
false
Checks if a module name is a view module.
## Examples
iex> is_view_module?("AutoDoc.PageView")
true
iex> is_view_module?("AutoDoc.PageController")
false
Checks if a module name is a view test module.
## Examples
iex> is_view_test_module?("AutoDocWeb.PageViewTest")
true
iex> is_view_test_module?("AutoDocWeb.PageView")
false
Converts a module name to a path.
## Examples
iex> module_name_to_path("AutoDoc.Utils")
"auto_doc/lib/auto_doc/utils.ex"
iex> module_name_to_path("AutoDoc.UtilsTest")
"auto_doc/test/auto_doc/utils_test.exs"
Guess the possible documentation's `operations.ex` file path.
Parses the file path from relative to usable type.
## Examples
iex> parse_file_path("lib/auto_doc/utils.ex")
"auto_doc/lib/auto_doc/utils.ex"
iex> parse_file_path("auto_doc/lib/auto_doc/utils.ex")
"auto_doc/lib/auto_doc/utils.ex"
Converts a path to a module name.
## Examples
iex> path_to_module_name("auto_doc/lib/auto_doc/utils.ex")
"AutoDoc.Utils"
iex> path_to_module_name("auto_doc/test/auto_doc/utils_test.exs")
"AutoDoc.UtilsTest"
Returns the name of the project container.
## Examples
iex> project_container_name()
"auto_doc"
Read file and returns the content.
Runs mix format
on given file.
## Examples
iex> run_mix_format("lib/auto_doc/utils.ex")
{:ok, "File formatted successfully."}
iex> run_mix_format("lib/auto_doc/utils.ex")
{:error, "File formatting failed. File: "lib/auto_doc/utils.ex""}
Converts a string to camelCase.
## Examples
iex> to_camel_case("helloWorld")
"helloWorld"
iex> to_camel_case("hello_world")
"helloWorld"
iex> to_camel_case("HelloWorld")
"helloWorld"
iex> to_camel_case("Invalid_Type")
** (ArgumentError)
** ...
Converts a string to PascalCase.
## Examples
iex> to_pascal_case("helloWorld")
"HelloWorld"
iex> to_pascal_case("hello_world")
"HelloWorld"
iex> to_pascal_case("HelloWorld")
"HelloWorld"
iex> to_pascal_case("Invalid_Type")
** (ArgumentError)
** ...
Converts a string to snake_case.
## Examples
iex> to_snake_case("helloWorld")
"hello_world"
iex> to_snake_case("hello_world")
"hello_world"
iex> to_snake_case("HelloWorld")
"hello_world"
iex> to_snake_case("Invalid_Type")
** (ArgumentError)
** ...
Write to file.