Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > 016232f1d9a3f7bee85855d35a2bca58 > files > 256

elixir-doc-1.7.2-1.mga7.noarch.rpm

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="ExDoc v0.19.1">
    <title>xref – Mix v1.7.2</title>
    <link rel="stylesheet" href="dist/app-240d7fc7e5.css" />
      <link rel="canonical" href="https://hexdocs.pm/mix/v1.7/Mix.Tasks.Xref.html" />
    <script src="dist/sidebar_items-0c0044e6e4.js"></script>
    
  </head>
  <body data-type="tasks">
    <script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
    <div class="main">
<button class="sidebar-button sidebar-toggle">
  <span class="icon-menu" aria-hidden="true"></span>
  <span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
  <span class="icon-theme" aria-hidden="true"></span>
  <span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">

  <a href="http://elixir-lang.org/docs.html" class="sidebar-projectLink">
    <div class="sidebar-projectDetails">
      <h1 class="sidebar-projectName">
Mix      </h1>
      <h2 class="sidebar-projectVersion">
        v1.7.2
      </h2>
    </div>
      <img src="assets/logo.png" alt="Mix" class="sidebar-projectImage">
  </a>

  <form class="sidebar-search" action="search.html">
    <button type="submit" class="search-button">
      <span class="icon-search" aria-hidden="true"></span>
    </button>
    <input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
  </form>

  <ul class="sidebar-listNav">
    <li><a id="extras-list" href="#full-list">Pages</a></li>

      <li><a id="modules-list" href="#full-list">Modules</a></li>

      <li><a id="exceptions-list" href="#full-list">Exceptions</a></li>

      <li><a id="tasks-list" href="#full-list">Mix Tasks</a></li>
  </ul>
  <div class="gradient"></div>
  <ul id="full-list" class="sidebar-fullList"></ul>
</section>

<section class="content">
  <div class="content-outer">
    <div id="content" class="content-inner">


      <h1>
        <small class="visible-xs">Mix v1.7.2</small>
mix xref        
          <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/tasks/xref.ex#L1" title="View Source" class="view-source" rel="help">
            <span class="icon-code" aria-hidden="true"></span>
            <span class="sr-only">View Source</span>
          </a>
      </h1>


        <section id="moduledoc">
<p>Performs cross reference checks between modules.</p>
<p>The unreachable and deprecated checks below happen every time
your project is compiled via <code class="inline">mix compile.xref</code>. See
<a href="Mix.Tasks.Compile.Xref.html"><code class="inline">Mix.Tasks.Compile.Xref</code></a> for more information.</p>
<h2 id="module-xref-modes" class="section-heading">
  <a href="#module-xref-modes" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Xref modes
</h2>

<p>The <code class="inline">xref</code> task expects a mode as first argument:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="nc">MODE</span></code></pre>
<p>All available modes are discussed below.</p>
<h3 id="module-unreachable" class="section-heading">
  <a href="#module-unreachable" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  unreachable
</h3>

<p>Prints all unreachable “file:line: module.function/arity” entries:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">unreachable</span></code></pre>
<p>The “file:line” represents the file and line a call to an unknown
“module.function/arity” is made.</p>
<p>The flag <code class="inline">--abort-if-any</code> can be used for the command to fail if
unreachable calls exist.</p>
<h2 id="module-deprecated" class="section-heading">
  <a href="#module-deprecated" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  deprecated
</h2>

<p>Prints all deprecated “file:line: module.function/arity” entries:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">deprecated</span></code></pre>
<p>The “file:line” represents the file and line a call to a deprecated
“module.function/arity” is made. This operation does not show deprecated
local calls (a call to a deprecated function or macro in the same module)
nor calls to deprecated functionality in Elixir itself.</p>
<p>The flag <code class="inline">--abort-if-any</code> can be used for the command to fail if
deprecated calls exist.</p>
<h3 id="module-callers-callee" class="section-heading">
  <a href="#module-callers-callee" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  callers CALLEE
</h3>

<p>Prints all callers of the given <code class="inline">CALLEE</code>, which can be one of: <a href="https://hexdocs.pm/elixir/Module.html"><code class="inline">Module</code></a>,
<code class="inline">Module.function</code>, or <code class="inline">Module.function/arity</code>. Examples:</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">callers</span><span class="w"> </span><span class="nc">MyMod</span><span class="w">
</span><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">callers</span><span class="w"> </span><span class="nc">MyMod</span><span class="o">.</span><span class="n">fun</span><span class="w">
</span><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">callers</span><span class="w"> </span><span class="nc">MyMod</span><span class="o">.</span><span class="n">fun</span><span class="o">/</span><span class="mi">3</span></code></pre>
<h3 id="module-graph" class="section-heading">
  <a href="#module-graph" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  graph
</h3>

<p>Prints a file dependency graph where an edge from <code class="inline">A</code> to <code class="inline">B</code> indicates
that <code class="inline">A</code> depends on <code class="inline">B</code>.</p>
<pre><code class="nohighlight makeup elixir"><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">graph</span><span class="w"> </span><span class="o">--</span><span class="n">format</span><span class="w"> </span><span class="n">stats</span></code></pre>
<p>The following options are accepted:</p>
<ul>
<li><p><code class="inline">--exclude</code> - paths to exclude</p>
</li>
<li><p><code class="inline">--label</code> - only shows relationships with the given label
The labels are “compile”, “struct” and “runtime” (runtime is now shown on the graph)</p>
</li>
<li><p><code class="inline">--only-nodes</code> - only shows the node names (no edges)</p>
</li>
<li><p><code class="inline">--source</code> - displays all files that the given source file references (directly or indirectly)</p>
</li>
<li><p><code class="inline">--sink</code> - displays all files that reference the given file (directly or indirectly)</p>
</li>
<li><p><code class="inline">--format</code> - can be set to one of:</p>
<ul>
<li><p><code class="inline">pretty</code> - prints the graph to the terminal using Unicode characters.
  Each prints each file followed by the files it depends on. This is the
  default except on Windows;</p>
</li>
<li><p><code class="inline">plain</code> - the same as pretty except ASCII characters are used instead of
  Unicode characters. This is the default on Windows;</p>
</li>
<li><p><code class="inline">stats</code> - prints general statistics about the graph;</p>
</li>
<li><p><code class="inline">dot</code> - produces a DOT graph description in <code class="inline">xref_graph.dot</code> in the
  current directory. Warning: this will override any previously generated file</p>
</li>
</ul>
</li>
</ul>
<p>The <code class="inline">--source</code> and <code class="inline">--sink</code> options are particularly useful when trying to understand
how the modules in a particular file interact with the whole system. You can combine
those options with <code class="inline">--label</code> and <code class="inline">--only-nodes</code> to get all files that exhibit a certain
property, for example:</p>
<pre><code class="nohighlight makeup elixir"><span class="c1"># To get all files that depend on lib/foo.ex</span><span class="w">
</span><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">graph</span><span class="w"> </span><span class="o">--</span><span class="n">sink</span><span class="w"> </span><span class="n">lib</span><span class="o">/</span><span class="n">foo</span><span class="o">.</span><span class="n">ex</span><span class="w"> </span><span class="o">--</span><span class="n">only</span><span class="o">-</span><span class="n">nodes</span><span class="w">

</span><span class="c1"># To get all files that depend on lib/foo.ex at compile time</span><span class="w">
</span><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">graph</span><span class="w"> </span><span class="o">--</span><span class="n">label</span><span class="w"> </span><span class="n">compile</span><span class="w"> </span><span class="o">--</span><span class="n">sink</span><span class="w"> </span><span class="n">lib</span><span class="o">/</span><span class="n">foo</span><span class="o">.</span><span class="n">ex</span><span class="w"> </span><span class="o">--</span><span class="n">only</span><span class="o">-</span><span class="n">nodes</span><span class="w">

</span><span class="c1"># To show general statistics about the graph</span><span class="w">
</span><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">graph</span><span class="w"> </span><span class="o">--</span><span class="n">format</span><span class="w"> </span><span class="n">stats</span><span class="w">

</span><span class="c1"># To limit statistics only to certain labels</span><span class="w">
</span><span class="n">mix</span><span class="w"> </span><span class="n">xref</span><span class="w"> </span><span class="n">graph</span><span class="w"> </span><span class="o">--</span><span class="n">format</span><span class="w"> </span><span class="n">stats</span><span class="w"> </span><span class="o">--</span><span class="n">label</span><span class="w"> </span><span class="n">compile</span></code></pre>
<h2 id="module-shared-options" class="section-heading">
  <a href="#module-shared-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Shared options
</h2>

<p>Those options are shared across all modes:</p>
<ul>
<li><p><code class="inline">--include-siblings</code> - includes dependencies that have <code class="inline">:in_umbrella</code> set
to true in the current project in the reports. This can be used to find
callers or to analyze graphs between projects</p>
</li>
<li><p><code class="inline">--no-compile</code> - does not compile even if files require compilation</p>
</li>
<li><p><code class="inline">--no-deps-check</code> - does not check dependencies</p>
</li>
<li><p><code class="inline">--no-archives-check</code> - does not check archives</p>
</li>
<li><p><code class="inline">--no-elixir-version-check</code> - does not check the Elixir version from mix.exs</p>
</li>
</ul>
<h2 id="module-configuration" class="section-heading">
  <a href="#module-configuration" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Configuration
</h2>

<p>All configuration for Xref should be placed under the key <code class="inline">:xref</code>.</p>
<ul>
<li><code class="inline">:exclude</code> - a list of modules and <code class="inline">{module, function, arity}</code> tuples to ignore when checking
cross references. For example: <code class="inline">[MissingModule, {MissingModule2, :missing_func, 2}]</code>
</li>
</ul>
        </section>

        <section id="summary" class="details-list">
          <h1 class="section-heading">
            <a class="hover-link" href="#summary">
              <span class="icon-link" aria-hidden="true"></span>
              <span class="sr-only">Link to this section</span>
            </a>
            Summary
          </h1>
          
  <div class="summary-functions summary">
    <h2>
      <a href="#functions">Functions</a>
    </h2>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#calls/1">calls(opts \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Returns a list of information of all the function calls in the project</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#run/1">run(args)</a>
  </div>
    <div class="summary-synopsis"><p>A task needs to implement <code class="inline">run</code> which receives
a list of command line args</p>
</div>
</div>
  </div>
          
        </section>



        <section id="functions" class="details-list">
          <h1 class="section-heading">
            <a class="hover-link" href="#functions">
              <span class="icon-link" aria-hidden="true"></span>
              <span class="sr-only">Link to this section</span>
            </a>
            Functions
          </h1>
<div class="detail" id="calls/1">
  
    <span id="calls/0"></span>
  <div class="detail-header">
    <a href="#calls/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">calls(opts \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/tasks/xref.ex#L211" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>calls(<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">keyword</a>()) :: [
  %{
    callee: {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">atom</a>(), <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">arity</a>()},
    caller_module: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(),
    line: <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">integer</a>(),
    file: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()
  }
]</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns a list of information of all the function calls in the project.</p>
<p>Each item in the list is a map with the following keys:</p>
<ul>
<li><code class="inline">:callee</code> - a tuple containing the module, function, and arity of the call
</li>
<li><code class="inline">:line</code> - an integer representing the line where the function is called
</li>
<li><code class="inline">:file</code> - a binary representing the file where the function is called
</li>
<li><code class="inline">:caller_module</code> - the module where the function is called
</li>
</ul>
<p>This function returns an empty list when used at the root of an umbrella
project because there is no compile manifest to extract the function call
information from. To get the function calls of each child in an umbrella,
execute the function at the root of each individual application.</p>
  </section>
</div>
<div class="detail" id="run/1">
    <div class="detail-header">
    <a href="#run/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">run(args)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/mix/lib/mix/tasks/xref.ex#L152" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
          </div>
  <section class="docstring">
<p>A task needs to implement <code class="inline">run</code> which receives
a list of command line args.</p>
<p>Callback implementation for <a href="Mix.Task.html#c:run/1"><code class="inline">Mix.Task.run/1</code></a>.</p>
  </section>
</div>
        </section>

          <footer class="footer">
        <p>
          <span class="line">
            Built using
            <a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener">ExDoc</a> (v0.19.1),
          </span>
          <span class="line">
            designed by
            <a href="https://twitter.com/dignifiedquire" target="_blank" rel="noopener" title="@dignifiedquire">Friedel Ziegelmayer</a>.
            </span>
        </p>
      </footer>
    </div>
  </div>
</section>
</div>
  <script src="dist/app-a0c90688fa.js"></script>
  
  </body>
</html>