| @@ -7,35 +7,108 @@ module Docs · 6 unmodified lines |
| 7 | 7 | name = at_css('h1').content.strip |
| 8 | 8 | name.remove! 'class ' |
| 9 | 9 | name.remove! 'struct ' |
| 10 | | − name.remove! 'module: ' |
| 10 | + name.remove! 'Module: ' |
| 11 | 11 | name.remove! %r{ \(.+\)} |
| 12 | 12 | name.sub! %r{(?<!\ )\(.+\)}, '()' |
| 13 | 13 | name.remove! %r{\.\z} |
| 14 | | − name.sub! 'tf.contrib', 'contrib' unless version == 'Guide' |
| 15 | 14 | name |
| 16 | 15 | end |
| 17 | 16 | |
| 18 | | − TYPE_BY_DIR = { |
| 19 | | − 'get_started' => 'Get Started', |
| 20 | | − 'programmers_guide' => 'Guide', |
| 21 | | − 'tutorials' => 'Tutorials', |
| 22 | | − 'performance' => 'Performance', |
| 23 | | − 'deploy' => 'Deploy', |
| 24 | | − 'extend' => 'Extend' |
| 25 | | − } |
| 26 | | − |
| 27 | 17 | def get_type |
| 28 | | − return 'Guides' if base_url.path.start_with?('/api_guides') |
| 29 | | − |
| 30 | | − if version == 'Guide' |
| 31 | | − TYPE_BY_DIR[subpath.split('/').first] |
| 18 | + if version == 'Guide' and base_url.path.start_with?('/guide') |
| 19 | + 'Guides' |
| 20 | + elsif version == 'Guide' and base_url.path.start_with?('/tutorials') |
| 21 | + 'Tutorials' |
| 22 | + elsif slug.start_with?('tf/audio') |
| 23 | + 'tf.audio' |
| 24 | + elsif slug.start_with?('tf/autograph') |
| 25 | + 'tf.autograph' |
| 26 | + elsif slug.start_with?('tf/bitwise') |
| 27 | + 'tf.bitwise' |
| 28 | + elsif slug.start_with?('tf/compat') |
| 29 | + 'tf.compat' |
| 30 | + elsif slug.start_with?('tf/config') |
| 31 | + 'tf.config' |
| 32 | + elsif slug.start_with?('tf/data') |
| 33 | + 'tf.data' |
| 34 | + elsif slug.start_with?('tf/debugging') |
| 35 | + 'tf.debugging' |
| 36 | + elsif slug.start_with?('tf/distribute') |
| 37 | + 'tf.distribute' |
| 38 | + elsif slug.start_with?('tf/dtypes') |
| 39 | + 'tf.dtypes' |
| 40 | + elsif slug.start_with?('tf/errors') |
| 41 | + 'tf.errors' |
| 42 | + elsif slug.start_with?('tf/estimator') |
| 43 | + 'tf.estimator' |
| 44 | + elsif slug.start_with?('tf/experimental') |
| 45 | + 'tf.experimental' |
| 46 | + elsif slug.start_with?('tf/feature_column') |
| 47 | + 'tf.feature_column' |
| 48 | + elsif slug.start_with?('tf/graph_util') |
| 49 | + 'tf.graph_util' |
| 50 | + elsif slug.start_with?('tf/image') |
| 51 | + 'tf.image' |
| 52 | + elsif slug.start_with?('tf/initializers') |
| 53 | + 'tf.initializers' |
| 54 | + elsif slug.start_with?('tf/io') |
| 55 | + 'tf.io' |
| 56 | + elsif slug.start_with?('tf/keras') |
| 57 | + 'tf.keras' |
| 58 | + elsif slug.start_with?('tf/linalg') |
| 59 | + 'tf.linalg' |
| 60 | + elsif slug.start_with?('tf/lite') |
| 61 | + 'tf.lite' |
| 62 | + elsif slug.start_with?('tf/lookup') |
| 63 | + 'tf.lookup' |
| 64 | + elsif slug.start_with?('tf/losses') |
| 65 | + 'tf.losses' |
| 66 | + elsif slug.start_with?('tf/math') |
| 67 | + 'tf.math' |
| 68 | + elsif slug.start_with?('tf/metrics') |
| 69 | + 'tf.metrics' |
| 70 | + elsif slug.start_with?('tf/nest') |
| 71 | + 'tf.nest' |
| 72 | + elsif slug.start_with?('tf/nn') |
| 73 | + 'tf.nn' |
| 74 | + elsif slug.start_with?('tf/optimizers') |
| 75 | + 'tf.optimizers' |
| 76 | + elsif slug.start_with?('tf/quantization') |
| 77 | + 'tf.quantization' |
| 78 | + elsif slug.start_with?('tf/queue') |
| 79 | + 'tf.queue' |
| 80 | + elsif slug.start_with?('tf/ragged') |
| 81 | + 'tf.ragged' |
| 82 | + elsif slug.start_with?('tf/random') |
| 83 | + 'tf.random' |
| 84 | + elsif slug.start_with?('tf/raw_ops') |
| 85 | + 'tf.raw_ops' |
| 86 | + elsif slug.start_with?('tf/saved_model') |
| 87 | + 'tf.saved_model' |
| 88 | + elsif slug.start_with?('tf/sets') |
| 89 | + 'tf.sets' |
| 90 | + elsif slug.start_with?('tf/signal') |
| 91 | + 'tf.signal' |
| 92 | + elsif slug.start_with?('tf/sparse') |
| 93 | + 'tf.sparse' |
| 94 | + elsif slug.start_with?('tf/strings') |
| 95 | + 'tf.strings' |
| 96 | + elsif slug.start_with?('tf/summary') |
| 97 | + 'tf.summary' |
| 98 | + elsif slug.start_with?('tf/sysconfig') |
| 99 | + 'tf.sysconfig' |
| 100 | + elsif slug.start_with?('tf/test') |
| 101 | + 'tf.test' |
| 102 | + elsif slug.start_with?('tf/tpu') |
| 103 | + 'tf.tpu' |
| 104 | + elsif slug.start_with?('tf/train') |
| 105 | + 'tf.train' |
| 106 | + elsif slug.start_with?('tf/version') |
| 107 | + 'tf.version' |
| 108 | + elsif slug.start_with?('tf/xla') |
| 109 | + 'tf.xla' |
| 32 | 110 | else |
| 33 | | − node = at_css('.devsite-nav-item.devsite-nav-active') |
| 34 | | − node = node.ancestors('.devsite-nav-item').first.at_css('.devsite-nav-title') |
| 35 | | − type = node.content |
| 36 | | − type.remove! %r{\.\z} |
| 37 | | − type = 'tf.contrib' if type.start_with?('tf.contrib') |
| 38 | | − type |
| 111 | + 'tf' |
| 39 | 112 | end |
| 40 | 113 | end |
| 41 | 114 | end |